Enviar Referente (Promotor) Directamente con Fragmentos de Código
Aprende cómo enviar un referente directamente utilizando fragmentos de código. Los métodos processCustomer y processCustomerAndBonus te permiten agregar al referente cuando el prospecto proporciona su correo electrónico. En Genius Referrals, lo hacemos fácil: permite que el prospecto ingrese el correo electrónico del referente en un campo designado en tu formulario de captura. En ésta guía paso a paso te mostramos cómo hacerlo.
Requisitos Previos
<?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">Email del Prospecto:</label>
<input type="email" id="customer-email" name="customerEmail" required>
<label for="referrer-email">Email del Referente:</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 -->
Paso 4: Verificar la Creación de la Referencia