JavaScript v3 Tracking (Deprecated)
JavaScript v3 tracking is fully deprecated and is no longer maintained. It is documented here for reference only, to support merchants who still have it installed.
Build every new integration on JavaScript v4 tracking (client-side) or server-side tracking. If you are still running v3, migrate to one of those.
Client-side tracking reports orders from the shopper's browser, using JavaScript on your "Thank You" page. Everything below describes the legacy v3 tracker.
Step 1 — Track visits
Copy the following code into the <head> section of every page on your site where you expect
affiliates to drive traffic. Replace YOUR-PUBLIC-KEY with the Public API key from your Refersion
account.
<!-- REFERSION TRACKING: BEGIN -->
<script src="//www.refersion.com/tracker/v3/YOUR-PUBLIC-KEY.js"></script>
<script>_refersion();</script>
<!-- REFERSION TRACKING: END -->
Step 2 — Send orders from your "Thank You" page
Add the code below to your "Thank You" or confirmation page — the page every customer reaches after completing an order. Use it as a starting template.
Within this code you must insert the customer's transaction information dynamically from the order. The sample values below are placeholders. Not all fields are required, but all are recommended; each one is described in Variable descriptions.
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.
For tracking to function, the click-tracking code from Step 1 and the code below 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',
'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:
| Value | Type | Required | Description |
|---|---|---|---|
order_id | String | Yes | Unique shopping-cart order ID or transaction number used to reference the purchase you're reporting. |
shipping | Number | No | Total shipping and handling the customer was charged for the order. |
tax | Number | No | Total tax the customer was charged for the order. |
discount | Number | No | Total in discounts that were applied to the order. |
discount_code | String | No | The discount or coupon code that was used on the order. |
currency_code | String | Yes | The three-letter currency code of the order totals you are reporting. Example: USD, CAD, GBP. |
Customer data
A customer represents the individual who purchased, and contains the following values:
| Value | Type | Required | Description |
|---|---|---|---|
first_name | String | No | Customer's first name. |
last_name | String | No | Customer's last name. |
email | String | No | Customer's email address. |
ip_address | String | No | The IP address of the customer. |
Item data
An item represents an individual product the customer ordered, and contains the following values:
| Value | Type | Required | Description |
|---|---|---|---|
sku | String | Yes | A unique product SKU or identifier. Can be blank, but we highly recommend populating it. |
quantity | Number | Yes | Total quantity ordered of the product. |
price | Number | Yes | Price of each item. For example, if the customer ordered 10 items at $5 each, report 5, not 50. Do not include currency symbols. |
Related
- JavaScript v4 tracking — the supported client-side tracker.
- Server-side tracking — the supported alternative.
- Order Tracking overview — how visit tracking and order reporting fit together.