In order to register your users on your iRefer campaign you can either user iRefer forms or your own forms. If you are already using a form to register (or to log in) your users, then you don't have to switch to iRefer forms. We can easily integrate with your existing forms - be it Hubspot, WooCommerce, Contact7, Gravity or any other custom forms.

Please add the following script code in the <head> section of your website html source.

Following code assumes that your form name is "checkout", email field name is "billing_email" and name fields are "billing_first_name" and "billing_last_name".

You would need to change the name of your form and name of the email and/or user-name fields in the code below.

Script code to create cookies to sign-up new participants

Use the following code if you are using your existing form for signing up new campaign participants (but not for specific action referrals).

<script>    

jQuery( document ).ready(function( $ ) {

//Change form name here
$('form[name="checkout"]').on("submit",function(e) {    

   //Get User-email -change email field name here
   var user_email = document.getElementsByName("billing_email")[0].value;

   //Get User-firstname -change firstname field name here
   var user_fname = document.getElementsByName("billing_first_name")[0].value;

   //Get User-lastname -change lastname field name here
   var user_lname = document.getElementsByName("billing_last_name")[0].value;

   var user_name = user_fname  + " " + user_lname;

   var domain_name = window.location.hostname;
   if (domain_name.startsWith("www.")){
      domain_name = domain_name.substring(4);
   }
   var days = 365;
   var date = new Date();
   date.setTime(date.getTime() + (days*24*60*60*1000));
   var expires = "; expires=" + date.toUTCString();

   //Register Sign-up
   document.cookie = "vsu_ref_email=" + user_email + expires + "; domain=." + domain_name + "; path=/";
   //Comment line below if name is not being used
   document.cookie = "vsu_ref_name=" + user_name + expires + "; domain=." + domain_name + "; path=/";

});

});

</script>

 

Script code to create cookies to register referrals on specific action

Use the following code if you are using your existing form for registering referrals on specific action (but not for signing up new campaign participants).

<script>    

jQuery( document ).ready(function( $ ) {

//Change form name here
$('form[name="checkout"]').on("submit",function(e) {      

   //Get User-email -change email field name here
   var user_email = document.getElementsByName("billing_email")[0].value;

   //Get User-firstname -change firstname field name here
   var user_fname = document.getElementsByName("billing_first_name")[0].value;

   //Get User-lastname -change lastname field name here
   var user_lname = document.getElementsByName("billing_last_name")[0].value;

   var user_name = user_fname  + " " + user_lname;

   var domain_name = window.location.hostname;
   if (domain_name.startsWith("www.")){
      domain_name = domain_name.substring(4);
   }
   var days = 365;
   var date = new Date();
   date.setTime(date.getTime() + (days*24*60*60*1000));
   var expires = "; expires=" + date.toUTCString();
   
   //Register Referral
   document.cookie = "vsu_visitor_ext_id=" + user_email + expires + "; domain=." + domain_name + "; path=/";
   //Comment line below if name is not being used
   document.cookie = "vsu_visitor_ext_name=" + user_name + expires + "; domain=." + domain_name + "; path=/";

});

});

</script>


You can remove or comment out the name section of Get User-name and name cookies, if you are not using user name (prefix each line with //).

If your form does not have a name tag then, use any of the following methods to identify the form -  

//Replace the below line with one of the following 
//$('form[name="checkout"]').on("submit",function(e) {

//Use the following line instead of above line if your form has no name but has an ID
$('#form-id').on("submit",function(e) {  

//Use the following line instead of above line if your form has no name and no ID but has a css class-name
$('.form-class-name').on("submit",function(e) {



 Please contact iRefer support if you have any queries.

Did this answer your question?