Send Referrer (Advocate) Directly with Code Snippets

This guide explains how to send advocate information using code snippets. The processCustomer and processCustomerAndBonus methods enable you to include the referrer’s email when the referred individual manually provides it.


To implement this, ask the prospect to enter the referrer’s email in an additional field on the capture page. The following steps will guide you through the process.

Prerequisites

Registration on the platform: Register at Genius Referrals.

Knowledge of Genius Referrals code snippets: This functionality was introduced in version 1.0.9 of the geniusreferrals-tool-box script

Note: Before starting, use the latest version of the geniusreferrals-tool-box script on your pages. You can generate the code snippets in the Integrations -> Code Snippets section.

Step 1: Obtain the Campaign Identifier

To obtain the campaign identifier (campaign-slug), we offer two methods:

METHOD 1: Visual Using the Genius Referrals Platform

  1. Log in to the Genius Referrals Platform.
  2. Click on "Program Settings" in the left-hand menu.
  3. Select the "Reward Campaigns" option to see the list of campaigns.
  4. Select the desired campaign and click on the "Actions" selector.
  5. Choose "View details" to see the general information about the campaign and the campaign ID.
METHOD 2: Using the Genius Referrals SDKs

<?php

require_once "../vendor/autoload.php";
$contentType = "application/json"; // The content type
$xAuthToken = "2f266b71b8038e6"; // Your API Token, you can get your token here https://app.geniusreferrals.com/en/settings/api-access
$accountSlug = 'sandbox';

$client = new GeniusReferralsLib\GeniusReferralsClient($contentType, $xAuthToken);

$campaignsController = $client->getCampaigns();

$campaigns = $campaignsController->getCampaigns($accountSlug);

foreach ($campaigns->data->results as $campaign) {
    echo "Campaign Name: " . $campaign->name . "\n";
    echo "Campaign Slug: " . $campaign->slug . "\n";
}
?>


Step 2: Prepare the Additional Field for the Referrer's Email

Add an additional field on the referral capture page so that the referred individual can enter the referrer's email address. Here's an example in HTML:

<form id="prospect-form">
    <label for="customer-email">Customer email:</label>
    <input type="email" id="customer-email" name="customerEmail" required>

    <label for="referrer-email">Referrer email:</label>
    <input type="email" id="referrer-email" name="referrerEmail" required>

    <input type="submit" value="Enviar">
</form>


Step 3: Send the Referrer's Information

Use the processCustomer or processCustomerAndBonus methods to send the prospect's and the referrer's information to Genius Referrals. Here's an example using the processCustomer method:

<!-- STARTING GENIUS REFERRALS TRACKING CODE -->
<script type="text/javascript">
!function (){
const submit = function (e){
const grFirstName=document.getElementsByName("gr_first_name")[0].value,
grLastName=document.getElementsByName("gr_last_name")[0].value,
grEmail=document.getElementsByName("customerEmail")[0].value,
grReferrerEmail=document.getElementById('referrer-email').value,
grMetadata='['+']';
if (grEmail != '') {
e.preventDefault();
const grSetting={
     "grTemplateSlug": "genius-bluebirds-template-990",
     "grCustomerFirstname": grFirstName,
     "grCustomerLastname": grLastName,
     "grCustomerEmail": grEmail,
     "grMetadata": grMetadata,
     "grCustomerCurrencyCode":  "USD", 
     "grCanRefer": "false",
     "grCampaignSlug": "get-10-off-for-90-days",
     "grReferrerEmail": grReferrerEmail
};
const button = this;
GRToolbox.processCustomer(grSetting).then(function(){
button.onclick=function(){};button.click();});}};
const grSettingCookie={
     "grCookieLifeTime": "180",
},
e=window,t=document;e.addEventListener("DOMContentLoaded",function(){const e=t.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://e9f87d8c82343264e6ba-2977c39e5e9390b1a89ab5ed2a171102.ssl.cf1.rackcdn.com/toolbox/geniusreferrals-toolbox_3.6.2.min.js",e.onload=function(){GRToolbox.catchReferrer(grSettingCookie);t.getElementById("gr-sign-up").onclick = submit;};const n=t.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)},!1)}();
</script>
<!-- ENDING GENIUS REFERRALS TRACKING CODE --> 

Step 4: Verify the Creation of the Referral

Once the processCustomer method is executed, an attempt will be made to create a connection between the advocate and the referred individual using the grReferrerEmail and grCampaignSlug parameters.
Was this page helpful?
LANGUAGE