Table of Contents

Conversion Tracking (JavaScript)

Tyra Earl Updated by Tyra Earl

What is the Conversion Tracking Script?

The Conversion Tracking script is added to a page that signifies that a conversion has happened. This could define a successful demo form submission, quote request form submission, e-commerce purchase, mailing list sign-up, or any other on-site action that you want to track. The script is triggered whenever the page is loaded by a visitor.

The Conversion Tracking script does three things:

  • Checks if the user is a referral, by checking for the existence of a Referral Rock cookie.
  • Creates a referral record and attributes it to the correct referring member, if the user is a referral.
  • Optionally adds parameters to the new referral record from your site. Examples include the referral's name, email address, and purchase amount.

This script does the hard work of creating a referral upon a sale or other desired action and adding information (parameters) about the new referral. 

The Conversion Tracking script is usually placed in one of the following areas:

  • A Thank You Page after a successful form submission.
  • A Confirmation Page after a successful e-commerce purchase.
  • A Welcome Page after a successful user sign-up.
It is best practice to place the script on a page that is only loaded once per user per conversion. Avoid placing the Conversion Tracking Script on a page that the same user will likely see multiple times, like a dashboard or homepage.

If you have more than one page that represents a conversion, you should add the Conversion Tracking Script to each page that represents a conversion. For instance, you may have slightly different thank you or welcome pages for different services or plans. Ensuring the script is on every page that represents a conversion will ensure that referrals are not missed.

If your conversion event cannot be defined by a page load (for instance a form submission that does not redirect to a Thank You page), or your website architecture does not use distinct page loads (for instance a Single-Page Application), we offer advanced functionality to trigger the Conversion Tracking Script using a JavaScript Function.

Conversion Tracking Settings

Referral Rock offers additional Conversion Tracking Settings you may use to customize the way conversion behaves in a particular program. To access these settings, navigate to your Program Editor > Additional Options (or click here)> Referral Options > Conversion Tracking Settings.

  • Automatically approve referral? - This option allows you to customize whether all Referrals will be automatically approved upon conversion for this program.
  • Tracking Expire - Allows you to customize the amount of days your Referral Rock cookie lives before expiring. Default value is 120 days.
  • Tracking with First Interaction Attribution - Determines which member will receive credit for a referral if the referral clicks on multiple member's referral links, and therefore multiple Referral Rock cookies exist.
    • Last Smart Interaction (Recommended) - Credit for the referral goes to the last member whose link was clicked by the referral.
    • First Interaction - Credit for the referral goes to the first member whose link was clicked by the referral. 
    • Last Interaction - Cookies are always replaced on a new referral link click, regardless of whether the referral clicks the same member's link more than once. This reduces tracking accuracy and fraud detection but can be useful if multiple members and referrals are expected to share the same device, as each referral link click on the same device will be tracked as a different user.

How to setup the Conversion Tracking Script on your website

We are always adding new platform-specific setup instructions, so check to see if there is an article on your platform here. If we haven't added your platform yet, or you have a custom-built website, continue below for generic instructions.
  1. Go to Settings Integrations then select Conversion Script or click here.
  2. Copy the code in the grey box and paste it into the HTML of the conversion page right before the closing </body> tag. If you do not have access to the HTML on your platform, look for a setting or plugin to install '3rd-party tracking scripts', '3rd-party JavaScript', or 'custom JavaScript'.
  3. (Optional) Configure the script to set the Referral Rock parameters (like name, email, etc.) to the merge tags, placeholder names, or JavaScript variable values on your site. While parameters are optional, they are highly recommended. In addition, setting the referral email address and/or external identifier is generally required during conversion in order to use the Referral Update Script in the future.
Avoid using a script manager such as Google Tag Manager for the Conversion Tracking Script, as it does not work with the parameters used by most services.

Some users' browsers or browser extensions may block 3rd party cookies. As an extra measure to ensure every referral is captured, we highly recommend placing our Universal Script on the page your referrals are redirected to. If the script is on this page, it will automatically take the member's encoded information from Referral Rock's cookie and apply it to a 1st party cookie, ensuring it will not be automatically removed.

Universal Script Example:

(function (f, r, n, d, b, y) { b = f.createElement(r), y = f.getElementsByTagName(r)[0]; b.async = 1; b.src = n; = 'RR_DIVID'; y.parentNode.insertBefore(b, y); })(document, 'script', '//');
Our Universal script should be placed on every landing page. Therefore if you have multiple programs, with separate landing pages, you will need to paste this script on each landing page

Testing your Conversion Tracking Script

Once you have completed the Conversion Tracking Script setup, we recommend you test them in order to ensure they are working correctly and you are pulling all the necessary Referral information.

The Integration Event Log

The Integration Event Log is a great place to make sure that referrals and their information is being captured properly. Using the Event Log, you can view a list of all the integration events that are associated with your Referral Rock account. When you select details, you are able to view all the data being passed by the integration scripts and confirm that the desired parameters are being passed correctly.


Using the Integration Event Log, you can confirm you are tracking conversions properly. However, if you check out your Event log and notice it is missing or pulling incorrect data, you might be making one of these common mistakes:

What Is Happening

What Causes It

How to Fix It

No events under 'List All' in the Event Log.

Integration Script is not firing.

Ensure the script is installed on the correct page. Ensure that your website allows the use of 3rd-party JavaScript. Ensure there are no JavaScript errors using the console in the developer menu of your browser (Chrome LinkFirefox Link).

Event Log is showing conversions but metadata is missing or incorrect.

Metadata is not correctly mapped to parameters.

Ensure your script does not contain any placeholder information (like firstname: "George", lastname: "Washington"). Ensure your parameters are using site specific placeholders/merge tags or JavaScript references to on-page information. Ensure your parameters are strings.

Event Log is showing: Info - No Tracking ID.

User did not go through a referral link before conversion.

This happens when the conversion script fires but the user does not have a Referral Rock cookie from a member on their browser. If you are testing conversion tracking, ensure that you click through a live member's referral link. This can also happen if users switch devices, as member cookies are device specific.

How did we do?

Universal Script: Convert 3rd party cookie to 1st party