PostHog

Track and analyze referral program data alongside product analytics in PostHog.

Note: The PostHog integration is only available to users on the GrowSurf Business plan or higher.

How It Works

After connecting, the PostHog integration transmits data to your PostHog account, enabling analysis and reporting on your referral program.

For referrers, when they are added to your campaign (e.g., they get a referral link generated) or if they click a social share button (like Facebook or LinkedIn), GrowSurf sends a PostHog event. For referred friends, if they sign up using your Share URL, GrowSurf also sends an event.

Under the hood, GrowSurf will load the PostHog JavaScript library, identify participants (both referrers and referred friends) by their email address, and track events. Rest assured, if PostHog is already installed, GrowSurf ensures the library is not loaded twice and prevents duplicate identity calls.

Tracked Events

The following events will be emitted with the growsurf_ prefix.

Event
Description
Explanation

growsurf_referral

[Referred friend] New referral signup

Records when a referred visitor signs up through a referral link. This includes:

  • Those who submit the form on your website that has referral tracking enabled (via the campaign editor)

  • Adding a referred participant via growsurf.addParticipant()

growsurf_referral_trigger

[Referred friend] Referral triggered

Records when a referred participant completes the desired qualifying action, which triggers a referral. Only applies when you are using growsurf.triggerReferral().

growsurf_signup

[Referrer] New referrer signup

Records when someone generates a referral link and joins the campaign as a participant.

This includes:

  • Direct signups (someone entering in their email address on the GrowSurf form)

  • Passing in an email address via URL parameter ?grsf_email

  • Passing in an email address via data-grsf-email attribute on an Embeddable Element

  • Adding a participant via growsurf.addParticipant()

growsurf_share

[Referred] Social media share

Records when a referrer shares their link by clicking 'Copy Link' or clicking a social media button

growsurf_invite

[Referrer] Email invite(s) sent

Records when a referrer sends invitation(s) via email

Example Events

Events correspond with the events listed in the growsurf.subscribe() method. To see examples of the raw JSON data, please see the Example Response section.


How to Set Up

Step 1: In Campaign Editor > 4. Options > Integrations, open the PostHog integration card and enter your PostHog project API key (you can find this from your PostHog project's settings page here).

Note: If you are 100% certain that you already have PostHog installed on your website, you do not need to enter in the PostHog project API key. Simply press Connect and the integration will be enabled. However, we recommend that you still enter it to account for URLs that do not have PostHog installed.

Step 2: Once connected, GrowSurf will have all events enabled by default. Disable any events that you do not want to track.

Important Note: Within your PostHog account, make sure to whitelist the URLs where these events occur. These are primarily two locations: your referral portal (which might be part of your user portal or web app, or the GrowSurf-hosted referral portal) and the referred friend's landing page (the Share URL you enter in the Campaign Editor > 5. Installation step).

Once GrowSurf events get emitted, you will see them show up in PostHog > Activity > Explore.

To filter just GrowSurf events, select an event like growsurf_share (if you don't see this option, you'll want to make sure there is at least one growsurf_share event that exists as PostHog will auto-generate this option).

Your screen should look like the image below:

Note: Please allow up to 15 minutes of processing time for events to appear (in some cases where PostHog is backed up, it can take longer).


Troubleshooting Tips

Here are common scenarios and how to troubleshoot them.

If you are seeing a wrongly identified user:

There are 5 different ways that GrowSurf participants can be added to your campaign. Please make sure that the GrowSurf participant email address that you are passing in matches the one you were expecting for the PostHog user:

  • If you pass in a data-grsf-email attribute to a GrowSurf embeddable element

  • If you pass in an email address via URL parameter ?grsf_email

  • If you are using growsurf.addParticipant()

  • If you enter an email address in via the GrowSurf form

  • If you are a referred friend and you submit the form that has referral tracking configured on it from the Campaign Editor > 5. Installation step

If you are not receiving events, but were expecting them:

  • Make sure you do not have any ad-blockers or browser extensions blocking requests to PostHog.

  • Make sure to whitelist the URL where events are being tracked (e.g, if your referrer clicks the Facebook share button from https://app.yoursite.com/refer, you'll want to make sure you whitelist that root domain. If a referred friend signs up on your Share URL, make sure to whitelist the Share URL as well).

  • If you just submitted an event, make sure that you've allowed up to 15 minutes for PostHog to process the event.

If you are receiving events, but were NOT expecting them:

  • To ensure no non-GrowSurf-related events are sent to your PostHog account, disconnect the integration completely. Simply toggling off all checkboxes is insufficient.

  • If you're receiving events without a GrowSurf-related suffix (e.g., growsurf_), it indicates that GrowSurf may not be emitting these events. Please check other parts of your code to find where these events might be occurring.

Last updated