← View All Guides
Salesforce logo
Integration Guide

How to Attribute Salesforce Campaigns to Referrals with GrowSurf

Link GrowSurf referral program data to Salesforce Campaigns for multi-channel marketing attribution.

Salesforce Campaigns are the standard way to measure marketing program effectiveness β€” and your referral program should be tracked as a campaign alongside email, paid ads, and events. By connecting GrowSurf referral data to Salesforce Campaign Members, you get a unified view of how referrals stack up against your other marketing channels.

This guide shows you how to create a Salesforce Campaign for your referral program, automatically add referred leads as Campaign Members, track member status progression, and build campaign ROI reports that prove the value of your referral program to marketing leadership.

Integration Steps

Step 1: Create a Salesforce Campaign for Your Referral Program

Set up a dedicated Salesforce Campaign to track all referral program activity.

  • Go to the Campaigns tab and create a new campaign
  • Name: "GrowSurf Referral Program - [Quarter/Year]"
  • Type: "Referral Program"
  • Status: "In Progress"
  • Define Campaign Member Statuses:
    • "Referred" (default) β€” initial referral
    • "Engaged" β€” clicked or signed up
    • "Converted" β€” became a paying customer
    • "Responded" β€” mark this as the "Responded" status for ROI calculation

Step 2: Automatically Add Referred Leads as Campaign Members

When GrowSurf generates a referral, automatically add the referred lead to your Salesforce Campaign.

  • After creating the Lead in Salesforce, add them as a Campaign Member
  • Use the Salesforce REST API: POST /services/data/v58.0/sobjects/CampaignMember
  • Set CampaignId, LeadId, and initial Status to "Referred"
  • Include referrer information in the Campaign Member's description

Step 3: Update Campaign Member Status on Referral Events

As the referral progresses through your funnel, update the Campaign Member status to reflect their journey.

  • Listen for GrowSurf's CAMPAIGN_REFERRAL_CONVERTED event
  • Look up the Campaign Member by Lead ID
  • Update status to "Converted" using PATCH /services/data/v58.0/sobjects/CampaignMember/{id}
  • This triggers Salesforce's campaign attribution tracking

Step 4: Connect Campaign Members to Opportunities

When a referred lead converts to an opportunity, Salesforce automatically associates the Campaign with the Opportunity for revenue attribution.

  • Ensure campaign influence settings are enabled in Setup > Campaign Influence
  • Set the referral campaign as a "Primary Campaign Source" on opportunities from referred leads
  • This enables accurate campaign ROI calculation in Salesforce reports

Step 5: Build Campaign Performance Reports

Create reports that show referral campaign performance alongside your other marketing campaigns.

  • Use the "Campaigns with Campaign Members" report type
  • Compare referral campaign metrics: total members, responded rate, and influenced revenue
  • Create a cross-campaign comparison showing cost per acquisition by channel
  • Track campaign ROI: (revenue influenced - campaign cost) / campaign cost

Step 6: Automate Campaign Hierarchies for Multiple Referral Programs

If you run multiple GrowSurf campaigns, organize them as child campaigns under a parent "Referral Programs" campaign.

  • Create a parent campaign called "Referral Programs - All"
  • Set individual GrowSurf campaign campaigns as children using the ParentId field
  • Roll-up reporting automatically aggregates child campaign metrics to the parent
  • This gives you both granular and aggregated referral program views

Code Snippets

// Add referred lead to Salesforce Campaign
async function addToCampaign(leadId, campaignId, referrerEmail) {
  const campaignMember = await conn.sobject('CampaignMember').create({
    CampaignId: campaignId,
    LeadId: leadId,
    Status: 'Referred',
    Description: `Referred by: ${referrerEmail}`
  });
  return campaignMember;
}

// Update campaign member status on conversion
async function updateCampaignMemberStatus(leadId, campaignId, newStatus) {
  // Find the campaign member
  const result = await conn.query(
    `SELECT Id FROM CampaignMember WHERE LeadId = '${leadId}' AND CampaignId = '${campaignId}'`
  );

  if (result.records.length > 0) {
    await conn.sobject('CampaignMember').update({
      Id: result.records[0].Id,
      Status: newStatus,
      FirstRespondedDate: new Date().toISOString()
    });
  }
}

// Full webhook handler
app.post('/api/growsurf-campaign-attribution', async (req, res) => {
  const { event, participant, referrer } = req.body;
  await conn.login(process.env.SF_USERNAME, process.env.SF_PASSWORD + process.env.SF_TOKEN);

  const SF_CAMPAIGN_ID = process.env.SF_REFERRAL_CAMPAIGN_ID;

  if (event === 'PARTICIPANT_REFERRED') {
    // Create lead and add to campaign
    const lead = await createReferralLead(participant, referrer);
    await addToCampaign(lead.id, SF_CAMPAIGN_ID, referrer.email);
  } else if (event === 'CAMPAIGN_REFERRAL_CONVERTED') {
    const leads = await conn.query(
      `SELECT Id FROM Lead WHERE GrowSurf_Participant_ID__c = '${participant.id}'`
    );
    if (leads.records.length > 0) {
      await updateCampaignMemberStatus(leads.records[0].Id, SF_CAMPAIGN_ID, 'Converted');
    }
  }

  res.json({ success: true });
});

Tips

Set Realistic Campaign Costs for ROI Calculation

Enter the total cost of your referral program (rewards paid, platform fees, development costs) as the Campaign's Budgeted Cost. This enables Salesforce's built-in campaign ROI formula to calculate accurate return on investment for your referral channel.

Use Campaign Influence for Multi-Touch Attribution

Enable Salesforce Campaign Influence (available in Enterprise edition) to track referral program influence alongside other campaigns that touched the same opportunity. This gives a more accurate picture when referral leads also interact with other marketing campaigns.

Create Quarterly Campaign Snapshots

Create new child campaigns each quarter (e.g., "GrowSurf Referrals - Q1 2026") to track performance trends over time. The parent campaign aggregates all-time metrics while child campaigns show quarterly performance.

FAQ

What's the difference between Campaign Attribution and Lead Source?

Lead Source is a single field on the Lead object (e.g., "Referral"). Campaign Attribution tracks which specific campaigns influenced a deal, with support for multiple campaigns and revenue attribution. Use both: set Lead Source to "Referral" and add the lead to a referral Campaign for full tracking.

Can I track both the referrer and the referred person as Campaign Members?

Yes. Add both to the Campaign with different statuses. The referrer could have status "Referrer" (a custom status you create) while the referred lead starts as "Referred." This lets you track total program participation including referrers.

How does this work with Salesforce's Customizable Campaign Influence model?

With Customizable Campaign Influence, you can assign percentage weights to each campaign that influenced a deal. Set your referral campaign's influence percentage based on how strongly you believe referrals drive conversions vs. other touches β€” typically 40-60% for the primary referral source.

Set up your refer a friend program with customer referral and affiliate program software that lowers your acquisition costs, increases customer loyalty, and saves you gobs of time.

Trusted by marketing and product teams at fast-growing B2C, fintech, and SaaS companies