When a new visitor submits a form on my site, can I restrict signups to only those who have been referred?

There are three ways to limit new participants being added to just referred visitors: via the automagic form detection setup in the campaign editor, via JavaScript, or via the REST API.


Restrict signups when using the automagic form detection method

If you are using the automagic form detection method for referral tracking, you can restrict individuals added as new participants to only individuals who were referred. Simply check the box next to "Only add new participants if they were referred" (Campaign Editor > Installation > Choose forms from your site to automatically track).

Restrict Signups Programmatically Using the JavaScript Web API

You can use the GrowSurf JavaScript Web API to detect if a visitor used a unique referral link to visit your webpage and only add a participant if that was the case. To do this you can view this tutorial or follow the steps below:

  1. In the Campaign Editor > Installation > Choose how to add participants to your campaign step, select "Programmatically using the GrowSurf API".
  2. Using JavaScript, add a new onSubmit event listener to the form that you want to track referrals on.
    1. If you are using a HubSpot form, there is a documented onFormSubmit callback you must use.
  3. Use the growsurf.getReferrerId() method to detect if a visitor used a unique referral link to visit your webpage.
    1. If the method returns a value, then they were referred. You can then add them as a participant using the appropriate method below:
      1. If your referral trigger is "Sign Up", then call growsurf.triggerReferral(). This will add the individual as a participant, trigger the referral, and the referrer will receive credit.
      2. If your referral trigger is "Sign Up + Qualifying Action", then call growsurf.addParticipant(). This will add the individual as a participant and associate the referrer to the new participant (but will NOT trigger the referral).
    2. If the method returns null, then do nothing.

Restrict Signups Programmatically Using the REST API

Alternatively, you can restrict signups through the REST API. If you want to restrict signups programmatically using the REST API, you can check if the referredBy field exists for the visitor and then add them as a participant using the /POST Add Participant endpoint.

Steps for Programmatic Restriction with the REST API:

  1. Check if the Visitor Was Referred: When the visitor submits a form, check if the referredBy field exists and contains a valid referrer ID or email.
  2. Add the Visitor as a Participant: If the referredBy field exists, call the /POST Add Participant endpoint to add them as a participant.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.