← View All Guides
Segment logo
Integration Guide

How to Track Referral Events with Segment + GrowSurf

Send GrowSurf referral events to Segment for unified analytics and downstream tool distribution.

Segment is the central hub of your data infrastructure β€” every customer interaction should flow through it, and your referral program is no exception. By routing GrowSurf referral events through Segment, you automatically distribute referral data to every tool in your stack: analytics platforms, CRMs, email tools, data warehouses, and more. One integration replaces dozens.

This guide shows you how to send GrowSurf referral events to Segment using the Track and Identify APIs. You'll learn how to structure referral events for maximum downstream utility, set up identity resolution for referred users, and configure Segment destinations to route referral data where it needs to go.

Integration Steps

Step 1: Define Your Referral Event Schema

Plan which GrowSurf events to track in Segment and what properties to include with each event.

  • Define these Segment events:
    • Referral Program Joined β€” when a participant is created
    • Referral Made β€” when a participant refers someone
    • Referral Converted β€” when a referred user converts
    • Referral Reward Earned β€” when a participant earns a reward
  • Standard properties for all events: participant_id, campaign_id, referral_code, timestamp
  • Event-specific properties: referrer details, referred user details, reward type and value

Step 2: Set Up Server-Side Event Tracking

Create a webhook handler that receives GrowSurf events and forwards them to Segment's Track API.

  • Install the Segment analytics-node library: npm install @segment/analytics-node
  • Initialize with your Segment Write Key
  • Map each GrowSurf webhook event to a Segment Track call
  • Include user identity (email) and all relevant properties

Step 3: Implement Identity Resolution for Referrals

Use Segment's Identify call to enrich user profiles with referral data so downstream tools have complete context.

  • Call analytics.identify() alongside each Track event
  • Set traits: referral_source, referred_by, referral_code, referral_count
  • For referred users, set an acquisition_channel trait to "referral"
  • This enriches user profiles in every downstream destination automatically

Step 4: Configure Segment Destinations

Enable the Segment destinations where referral data should flow.

  • Analytics: Google Analytics, Mixpanel, Amplitude β€” for referral funnel analysis
  • CRM: HubSpot, Salesforce β€” for referral lead tracking
  • Email: Klaviyo, Customer.io β€” for referral email flows
  • Data Warehouse: BigQuery, Snowflake β€” for deep referral analytics
  • For each destination, map Segment event names to the destination's expected format

Step 5: Validate Event Data Quality

Use Segment's Debugger and Protocols to ensure referral events are structured correctly.

  • Go to Connections > Sources > [Your Source] > Debugger
  • Trigger test referral events from GrowSurf
  • Verify all events appear with correct names, properties, and user IDs
  • Set up Segment Protocols (tracking plan) to enforce your referral event schema
  • Configure Protocols to block or flag events that don't match the expected schema

Step 6: Build Referral Analytics from Segment Data

Use the referral data flowing through Segment to build analytics across your connected tools.

  • In your analytics tool: create a referral funnel (Joined β†’ Made Referral β†’ Referral Converted)
  • In your CRM: create referral-attributed lead reports
  • In your data warehouse: build referral LTV cohort analysis
  • All powered by the same event data, flowing automatically through Segment

Code Snippets

// Send GrowSurf events to Segment
const { Analytics } = require('@segment/analytics-node');
const analytics = new Analytics({ writeKey: process.env.SEGMENT_WRITE_KEY });

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

  // Map GrowSurf events to Segment events
  const eventMap = {
    'PARTICIPANT_CREATED': 'Referral Program Joined',
    'PARTICIPANT_REFERRED': 'Referral Made',
    'CAMPAIGN_REFERRAL_CONVERTED': 'Referral Converted'
  };

  const segmentEvent = eventMap[event];
  if (!segmentEvent) return res.json({ skipped: true });

  // Identify the participant with referral traits
  analytics.identify({
    userId: participant.email,
    traits: {
      email: participant.email,
      firstName: participant.firstName,
      lastName: participant.lastName,
      referral_code: participant.referralCode,
      referral_count: participant.referralCount || 0,
      referral_source: 'growsurf',
      referred_by: referrer?.email || null,
      acquisition_channel: referrer ? 'referral' : 'organic'
    }
  });

  // Track the referral event
  analytics.track({
    userId: participant.email,
    event: segmentEvent,
    properties: {
      participant_id: participant.id,
      referral_code: participant.referralCode,
      campaign_id: participant.campaignId,
      referrer_email: referrer?.email,
      referrer_id: referrer?.id,
      referrer_referral_count: referrer?.referralCount,
      timestamp: new Date().toISOString()
    }
  });

  await analytics.flush();
  res.json({ success: true, event: segmentEvent });
});

Tips

Standardize Event Names Across Sources

Use consistent event naming across all your Segment sources. If you already track "User Signed Up" from your app, your GrowSurf "Referral Program Joined" event should follow the same naming convention (Title Case, past tense). This makes cross-source analysis much easier.

Include the Referral Source in All User Profiles

Always set an acquisition_channel trait on the Identify call for referred users. This single trait lets every downstream tool segment users by acquisition channel β€” enabling referral vs. organic comparisons across your entire stack without custom integration work.

Use Segment Protocols to Enforce Data Quality

Define a tracking plan for your referral events in Segment Protocols. This catches schema violations (missing properties, wrong types) before bad data reaches downstream tools. Data quality issues in referral tracking are hard to fix retroactively, so prevent them upfront.

FAQ

Why route GrowSurf data through Segment instead of integrating with each tool directly?

Segment saves you from building and maintaining separate integrations for each downstream tool. One webhook handler sends data to Segment, and Segment distributes it to 300+ destinations automatically. If you add a new analytics tool or CRM, you just enable the destination β€” no new code needed.

How do I handle anonymous referred users who haven't signed up yet?

Use Segment's anonymous ID for users who clicked a referral link but haven't created an account. When they sign up, call analytics.alias() to merge their anonymous activity with their identified profile. This gives you a complete view of the referral journey from click to conversion.

Can I use Segment to trigger GrowSurf conversions based on events from other tools?

Not directly from Segment, but you can use Segment's webhook destination to call GrowSurf's API when specific events occur. For example, when a "Payment Completed" event flows through Segment, use a webhook destination to call GrowSurf's participant conversion endpoint.

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