← View All Guides
Customer.io logo
Integration Guide

How to Track Referral Events in Customer.io with GrowSurf

Send GrowSurf referral events to Customer.io for behavioral segmentation and lifecycle campaign triggers.

Customer.io's power lies in its event-driven data model β€” every action a user takes can be tracked as an event and used to trigger campaigns, build segments, and analyze behavior. By sending GrowSurf referral events to Customer.io, you create a complete picture of each user's referral journey that powers intelligent automation and precise targeting.

This guide focuses on the data architecture side of the Customer.io + GrowSurf integration. You'll learn how to structure referral events, set up customer attributes, build event-based segments, and create data-driven campaigns that respond to referral behavior in real time.

Integration Steps

Step 1: Plan Your Referral Event Schema in Customer.io

Design the events and attributes you'll track to ensure maximum utility for segmentation and campaigns.

  • Events to track (actions that happen at a point in time):
    • referral_program_joined β€” with attributes: campaign_name, source
    • referral_shared β€” with attributes: share_method (email, social, link)
    • referral_friend_signed_up β€” with attributes: friend_email, referral_code
    • referral_converted β€” with attributes: conversion_value, product
    • referral_reward_claimed β€” with attributes: reward_type, reward_value
  • Customer attributes to maintain (persistent profile data):
    • referral_code, referral_link, total_referrals, referral_tier, referred_by

Step 2: Implement Event Tracking via API

Build the integration that sends GrowSurf events to Customer.io's Track API.

  • Use Customer.io's track endpoint to record events
  • Use the identify endpoint to create/update customer profiles
  • Send events server-side from your webhook handler (not client-side)
  • Include timestamps to ensure accurate event ordering

Step 3: Build Event-Based Segments

Create Customer.io segments using referral events for precise campaign targeting.

  • Go to Segments > Create Segment
  • "Recent Referrers": People who performed "referral_friend_signed_up" in last 7 days
  • "Inactive Participants": People who performed "referral_program_joined" more than 30 days ago AND did NOT perform "referral_shared" in last 30 days
  • "High-Value Referrers": People where attribute total_referrals >= 5
  • "Unconverted Referrals": People who performed "referral_program_joined" AND attribute referred_by exists AND did NOT perform "purchase"

Step 4: Create Data-Driven Referral Campaigns

Build campaigns that use event data for intelligent triggering and personalization.

  • Trigger on specific event + attribute combinations for precision targeting
  • Example: Send email only when "referral_friend_signed_up" AND total_referrals = 1 (first referral ever)
  • Use event attributes in email templates: "{{event.friend_email}} just signed up using your link!"
  • Branch campaigns based on referral tier for personalized content

Step 5: Set Up Event-Triggered Webhooks from Customer.io

Use Customer.io's outgoing webhooks to trigger actions in GrowSurf or other tools based on Customer.io campaign engagement.

  • In your Customer.io campaign, add a webhook action
  • Call your server when someone clicks a referral link in an email
  • Use this to track email-driven referral sharing activity back in GrowSurf
  • Create a feedback loop: email engagement β†’ more sharing β†’ more referrals

Step 6: Analyze Referral Event Patterns

Use Customer.io's analytics to understand referral behavior patterns.

  • Analyze time-between-events: how long between joining the program and making the first referral?
  • Track event frequency: how often do active referrers share?
  • Identify correlations: do users who share via email convert more referrals than social sharers?
  • Use these insights to optimize your referral program and messaging

Code Snippets

// Complete Customer.io event tracking for GrowSurf
const { TrackClient, RegionUS } = require('customerio-node');
const cio = new TrackClient(
  process.env.CIO_SITE_ID,
  process.env.CIO_API_KEY,
  { region: RegionUS }
);

// Event tracking with rich attributes
async function trackReferralEvent(participant, eventName, extraData = {}) {
  // Ensure customer profile exists with latest data
  await cio.identify(participant.email, {
    email: participant.email,
    first_name: participant.firstName,
    last_name: participant.lastName,
    referral_code: participant.referralCode,
    referral_link: participant.shareUrl,
    total_referrals: participant.referralCount || 0,
    referral_tier: getReferralTier(participant.referralCount || 0)
  });

  // Track the specific event
  await cio.track(participant.email, {
    name: eventName,
    data: {
      campaign_id: participant.campaignId,
      referral_code: participant.referralCode,
      ...extraData,
      tracked_at: Math.floor(Date.now() / 1000)
    }
  });
}

function getReferralTier(count) {
  if (count >= 10) return 'champion';
  if (count >= 5) return 'power_referrer';
  if (count >= 1) return 'active';
  return 'new_participant';
}

// Webhook handler with complete event mapping
app.post('/api/growsurf-to-cio', async (req, res) => {
  const { event, participant, referrer } = req.body;

  switch (event) {
    case 'PARTICIPANT_CREATED':
      await trackReferralEvent(participant, 'referral_program_joined', {
        referred_by: referrer?.email,
        source: referrer ? 'referral' : 'organic'
      });
      break;
    case 'PARTICIPANT_REFERRED':
      // Track for the referrer
      await trackReferralEvent(referrer, 'referral_friend_signed_up', {
        friend_email: participant.email,
        friend_name: participant.firstName
      });
      break;
    case 'CAMPAIGN_REFERRAL_CONVERTED':
      await trackReferralEvent(participant, 'referral_converted', {
        referrer_email: referrer?.email
      });
      break;
  }

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

Tips

Track Share Method for Channel Optimization

When possible, track how participants share their referral links (email, Twitter, Facebook, WhatsApp, link copy). This data reveals which sharing channels drive the most conversions, letting you promote the most effective sharing methods in your referral emails and prompts.

Use Event Frequency for Engagement Scoring

Build a referral engagement score based on event frequency. A participant who shares once is less engaged than one who shares weekly. Use Customer.io's event count and recency in your segment definitions to differentiate between one-time participants and consistent advocates.

Set Up Event Backfilling for Historical Data

When you first set up the integration, backfill historical GrowSurf participant data into Customer.io using GrowSurf's API. This ensures your segments and campaigns have accurate data from day one, not just from the integration start date.

FAQ

What's the difference between Customer.io events and attributes?

Events are timestamped actions ("referral_made at 2pm on Jan 5") that can trigger campaigns and be counted in segments ("performed X event in last 30 days"). Attributes are persistent properties on a customer profile ("total_referrals = 5") that are always current. Use events for tracking behavior and attributes for current state.

Can I track anonymous referral link clicks before the user identifies themselves?

Customer.io supports anonymous events using a device ID. When someone clicks a referral link, track the event with an anonymous identifier. When they later sign up and you identify them, merge the anonymous and identified profiles to get the complete journey. This requires client-side JavaScript tracking.

How long does Customer.io retain event data?

Customer.io retains event data based on your plan β€” typically 90 days to unlimited. Attributes on customer profiles are retained indefinitely. For long-term referral analytics, store aggregated data in attributes (total_referrals, first_referral_date) rather than relying on event queries for historical data.

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