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.
Knowledge of Genius Referrals code snippets: This functionality was introduced in version 1.0.9 of the geniusreferrals-tool-box script
<?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";
}
?>
<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>
<!-- 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 -->