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

There are three supported ways to ensure only referred visitors are added as participants: using the automagic form detection setup (default behavior), via JavaScript SDK, or via the REST API.


Restrict Signups Using the Automagic Form Detection Method

If you are using the automagic form detection method for referral tracking, only referred visitors will be added as participants by default. This is the recommended and simplest approach, as no additional configuration is required.

Restrict Signups Programmatically Using the JavaScript SDK

You can use the GrowSurf JavaScript SDK to ensure only referred visitors are added as participants by using the growsurf.addReferredParticipant()  method. This method automatically validates whether a visitor has a valid referral before adding them as a participant.

  1. To implement this, follow these steps:

    In the Program Editor > Installation > Choose your referral tracking method step, select "Programmatically using the GrowSurf API".

    On form submission, call growsurf.addReferredParticipant()   with the participant data. This method will do the following:

    • Automatically detect a referral from the grsf   URL parameter or browser cookie
    • Only add the participant if a valid referrer exists
    • Return added: false   with a reason such as no_referrer , invalid_referrer , or participant_already_exists   if the signup should not be added

If the visitor was referred, the participant will be created and linked to the referrer. If not, no participant will be added.

Restrict Signups Programmatically Using the REST API

Alternatively, you can restrict signups through the REST API. If you want to restrict signups programmatically via the REST API, check whether the referredByfield exists for the referred friend, 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 referred friend 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 a validreferredBy 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.