growsurf.addParticipant(). Let's say you have a signup function called
signUpFree(), here's what that looks like:
<div data-grsf-block-button></div>anywhere in your HTML, and clicking the element will open up the GrowSurf window.
onclick="growsurf.open()"to any HTML element
<div data-grsf-block-form></div>anywhere in your HTML, and the GrowSurf form will appear. If you want your participant to be already logged in and see their stats (instead of the form), you can add an attribute
data-grsf-emailto have the value of the participant's email.
#referral-countHTML elements to show their unique referral link and referral count.
https://replaceme.comwith your redirect URL.
<HEAD>of the HTML source code. This should be the same page(s) where you have included the GrowSurf Universal Code. Remember to replace
https://replaceme.comat line 7 with your redirect URL.
growsurf.getParticipantById(). In this example, we have a simple page with a
h1#headerthat will display as "Emily S. invited you to pet puppies on-demand" if a referrer exists, otherwise it will display as "Pet puppies on-demand".
growsurf.triggerReferral()in the example below. The example code also assumes that you have setup a submit listener on your form which will listen for submission events and invoke the callback function described below. If you are not sure how to add a form submission listener here is an example.
form.addEventListenersnippets of code. The
window.addEventListenerlistens for the GrowSurf script
grsfReadyevent which is emitted when the GrowSurf script is ready. Once the GrowSurf script is ready we are adding a
submitevent listener to our form
form.addEventListenerto listen for submission events. You will need to get the form element using
document.getElementByIdusing the id of your form for this to work - this is just an example. The next piece of code we will look at is the
userEmailinput using the id or name of the input element of your form - this is just an example. Please note that this example will attempt to add a participant on all form submissions regardless if the form is valid or not. If you wish to perform some validation before adding the participant that will require some extra coding to do so but is out of scope for this example.
phone-numberat lines 6 and 7 in the code snippets below).