Client-side Tracking

Step 1 - Tracking Visits

Please copy/paste the following code into the <head> section of every page on your website where you expect your affiliates to drive traffic. Make sure to replace YOUR-PUBLIC-KEY below with the Public API key from your Refersion account. This code snippet is responsible for tracking clicks when affiliates refer customers to your website.

<!-- REFERSION TRACKING: BEGIN -->
<script src="//www.refersion.com/tracker/v3/YOUR-PUBLIC-KEY.js"></script>
<script>_refersion();</script>
<!-- REFERSION TRACKING: END -->

Step 2 - Sending orders via Javascript on a "Thank You Page"

For this type of tracking, you must add code to your "thank you" or confirmation page. This would be the page that all customers are directed to after completing their order. This code is responsible for sending the order data to Refersion.

Below we've provided a sample code snippet with dummy data that you can use as a starting template. Not all data is required, but all is recommended. A description of each field is available at the end of this article.

When adding this code to your real website you must dynamically insert the customer's transaction information from the respective order within the code snippet. As an example, "[email protected]" would be replaced with a real customer's email, "TESTCOUPON" would be replaced with an actual code used on the order, and so forth.

For best performance, place this code just before the </body> tag in your HTML remembering to replace YOUR-PUBLIC-KEY with the Public API key from your Refersion account.

🚧

In order to function properly, the click tracking code described in Step 1 and this code must run on the same domain and security level (http/https).

<!-- REFERSION TRACKING: BEGIN -->
<script src="//www.refersion.com/tracker/v3/YOUR-PUBLIC-KEY.js"></script>
<script>
_refersion(function(){

    _rfsn._addTrans({
        'order_id': '12345',
        'shipping': '11.90',
        'tax': '5.23',
        'discount': '2.32',
        'discount_code': 'TESTCOUPON',
        'currency_code': 'USD'
    });

    _rfsn._addCustomer({
        'first_name': 'Nancy',
        'last_name': 'Parker',
        'email': '[email protected]',
        'ip_address': '808.53.77.22'
    });

    _rfsn._addItem({
        'sku': 'DD23444',
        'quantity': '2',
        'price': '100'
    });

    _rfsn._addItem({
        'sku': 'XJ66778',
        'quantity': '3',
        'price': '50'
    });

    _rfsn._addItem({
        'sku': 'MP39592',
        'quantity': '2',
        'price': '1000'
    });

    _rfsn._sendConversion();

});
</script>
<!-- REFERSION TRACKING: END -->

Variable Descriptions

Transaction Data

A transaction represents the entire order that occurred, and contains the following values:

ValueTypeRequiredDescription
order_idStringYesUnique shopping cart order ID or transaction number used to reference the purchase that you're reporting.
shippingNumberNoTotal shipping and handling the customer was charged for the order.
taxNumberNoTotal tax the customer was charged for the order.
discountNumberNoTotal in discounts that were applied to the order.
discount_codeStringNoThe discount or coupon code that was used on the order.
currency_codeStringYesThe three letter currency code of the order totals that you are reporting. Example: USD, CAD, GBP.

Customer Data

A customer represents the individual customer who purchased, and contains the following values:

ValueTypeRequiredDescription
first_nameStringNoCustomer’s first name.
last_nameStringNoCustomer’s last name.
emailStringNoCustomer’s email address.
ip_addressStringNoThe IP address of the customer.

Item Data

An item represents an individual product that the customer had ordered, and contains the following values:

ValueTypeRequiredDescription
skuStringYesA unique Product SKU or identifier ID. Can be blank, but we highly recommend that you populate the field.
quantityNumberYesTotal quantity ordered of the product.
priceNumberYesPrice of each item. For example, if the customer ordered 10 items at $5 each, you should report $5, not $50. Do not include currency symbols.