← View All Guides
Salesforce logo
Integration Guide

How to Track Referral Leads in Salesforce with GrowSurf

Automatically create and tag leads in Salesforce when referrals come through your GrowSurf program.

Salesforce is the backbone of enterprise sales operations, and your referral program data needs to live there alongside every other lead source. By integrating GrowSurf with Salesforce, you can automatically create leads tagged with referral source information, giving your sales team immediate visibility into which prospects were referred and by whom.

This guide covers building a GrowSurf-to-Salesforce lead sync pipeline. You'll learn how to create custom fields for referral data, set up automated lead creation from GrowSurf webhooks, configure lead assignment rules for referred leads, and build Salesforce reports to track referral lead performance through your pipeline.

Integration Steps

Step 1: Create Custom Fields on the Salesforce Lead Object

Add custom fields to your Lead object in Salesforce to store referral program data from GrowSurf.

  • Go to Setup > Object Manager > Lead > Fields & Relationships
  • Create these custom fields:
    • Referral_Source__c (Text) β€” set to "GrowSurf"
    • Referred_By__c (Email) β€” the referrer's email address
    • Referral_Code__c (Text) β€” GrowSurf referral code
    • GrowSurf_Participant_ID__c (Text, External ID) β€” for deduplication
    • Referral_Date__c (Date) β€” when the referral was created
  • Add these fields to your Lead page layout

Step 2: Set Up a Connected App for API Access

Create a Salesforce Connected App to authenticate your webhook handler with the Salesforce REST API.

  • Go to Setup > App Manager > New Connected App
  • Enable OAuth settings with the api and refresh_token scopes
  • Note the Consumer Key and Consumer Secret
  • Use the Username-Password OAuth flow for server-to-server integration

Step 3: Build the Webhook Handler for Lead Creation

Create an endpoint that receives GrowSurf webhook events and creates or updates leads in Salesforce via the REST API.

  • Listen for PARTICIPANT_CREATED and PARTICIPANT_REFERRED events
  • Authenticate with Salesforce using OAuth 2.0
  • Use the Salesforce REST API to create Lead records: POST /services/data/v58.0/sobjects/Lead
  • Include all referral custom fields in the request body

Step 4: Configure Lead Assignment Rules for Referrals

Set up Salesforce Lead Assignment Rules that route referred leads to the right sales reps or queues.

  • Go to Setup > Lead Assignment Rules
  • Add a rule entry: If Referral_Source__c equals "GrowSurf", assign to your referral lead queue or specific rep
  • Set priority higher than default rules so referral leads are always handled first
  • Enable auto-response rules to send immediate acknowledgment emails to referred leads

Step 5: Create a Referral Lead Report and Dashboard

Build a Salesforce report that tracks referral lead volume, conversion rates, and pipeline contribution.

  • Create a new report using the "Leads" report type
  • Filter by Referral_Source__c = "GrowSurf"
  • Add columns: Lead Name, Referred By, Status, Created Date, Converted
  • Group by Lead Status to see funnel progression
  • Add to a Referral Program dashboard with charts showing trends over time

Step 6: Sync Lead Status Changes Back to GrowSurf

When a referred lead progresses through your Salesforce pipeline, update GrowSurf to trigger appropriate rewards and maintain data consistency.

  • Create a Salesforce Process Builder or Flow that fires when Lead Status changes
  • Use an HTTP callout to GrowSurf's API when a lead is qualified or converted
  • Call POST /v2/campaign/{id}/participant/{participantId}/convert to mark the referral as converted
  • This triggers the referrer's reward in GrowSurf automatically

Code Snippets

// Create referred lead in Salesforce via REST API
const jsforce = require('jsforce');

const conn = new jsforce.Connection({
  loginUrl: process.env.SF_LOGIN_URL
});

app.post('/api/growsurf-to-salesforce', async (req, res) => {
  const { event, participant, referrer } = req.body;

  await conn.login(process.env.SF_USERNAME, process.env.SF_PASSWORD + process.env.SF_TOKEN);

  if (event === 'PARTICIPANT_REFERRED' || event === 'PARTICIPANT_CREATED') {
    // Check for existing lead to avoid duplicates
    const existing = await conn.query(
      `SELECT Id FROM Lead WHERE GrowSurf_Participant_ID__c = '${participant.id}'`
    );

    if (existing.records.length === 0) {
      const lead = await conn.sobject('Lead').create({
        FirstName: participant.firstName || '',
        LastName: participant.lastName || participant.email.split('@')[0],
        Email: participant.email,
        Company: participant.metadata?.company || '[Not Provided]',
        LeadSource: 'Referral Program',
        Referral_Source__c: 'GrowSurf',
        Referred_By__c: referrer ? referrer.email : '',
        Referral_Code__c: participant.referralCode,
        GrowSurf_Participant_ID__c: participant.id,
        Referral_Date__c: new Date().toISOString().split('T')[0]
      });
      console.log('Created Salesforce lead:', lead.id);
    }
  }

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

Tips

Use External IDs for Idempotent Upserts

Set the GrowSurf_Participant_ID__c field as an External ID in Salesforce. This lets you use Salesforce's upsert operation instead of separate create/update logic, automatically handling deduplication without extra code.

Enrich Referral Leads with Company Data

Use Salesforce's data enrichment tools or a third-party service like Clearbit to auto-fill company information on referral leads. GrowSurf captures email at minimum β€” enrichment adds company size, industry, and revenue data that helps your sales team prioritize.

Set Up Real-Time Alerts for High-Value Referrals

Create Salesforce Flow alerts that notify sales managers when a referral lead comes from a target account or matches your ideal customer profile. Fast response times on high-quality referral leads significantly increase win rates.

FAQ

Can I use Salesforce's built-in web-to-lead instead of API integration?

Web-to-Lead is simpler but limited β€” it doesn't support custom field mapping or error handling. For a production referral program, the API integration gives you more control, better deduplication, and the ability to handle edge cases like updating existing leads.

How do I handle the Salesforce requirement for Last Name and Company on leads?

GrowSurf may only capture an email address. Set fallback values: use the email prefix as Last Name and "[Not Provided]" as Company. Alternatively, collect these fields during GrowSurf sign-up by adding custom fields to your referral widget.

Can I track referral leads through Salesforce Opportunities after lead conversion?

Yes. When you convert a Lead to a Contact and Opportunity in Salesforce, the custom referral fields can be mapped to corresponding fields on the Contact and Opportunity objects. Set up field mapping in Setup > Lead Settings > Map Lead Fields.

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