TUNE Javascript Tracking is a privacy-compliant tracking method with the accuracy of server-side postbacks but the setup effort of client-side pixel tracking. This tutorial will walk you through the steps of setting up your Offer, adding the Javascript snippets to your page to store sessions, and then post a conversion.
The article includes the following sections:
Basic Integration
Configure the Offer
- Set the offer's tracking protocol to Server Postback w/Transaction ID
- Add transaction_id={transaction_id} to the Default Offer URL
For example, if you're directing traffic to:
https://advertisersite.com/storefront
You'll want to ensure the transaction_id is being appended like so:
https://advertisersite.com/storefront?transaction_id={transaction_id}
Add the Javascript Code
1. Paste the code below to the head of any site to add the tracking functionality:
<script>
!function(){var o=window.tdl=window.tdl||[];if(o.invoked)window.console&&console.error&&console.error("Tune snippet has been included more than once.");else{o.invoked=!0,o.methods=["init","identify","convert"],o.factory=function(n){return function(){var e=Array.prototype.slice.call(arguments);return e.unshift(n),o.push(e),o}};for(var e=0;e<o.methods.length;e++){var n=o.methods[e];o[n]=o.factory(n)}o.init=function(e){var n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://js.go2sdk.com/v2/tune.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(n,t),o.domain=e}}}();
tdl.init("YOUR TRACKING SERVER DOMAIN")
tdl.identify()
</script>
You'll need to replace "YOUR TRACKING SERVER DOMAIN" with your tracking domain which can be found in your TUNE account under Offers > Manage Offers by selecting an offer in the Generate Tracking panel. Unless you have set a custom tracking domain, it will look something this:
https://demo.go2cloud.org
The above code will load additional methods asynchronously as to not affect your page's load time.
2. Paste the code below to the page where you want to track a conversion:
<script>
!function(){var o=window.tdl=window.tdl||[];if(o.invoked)window.console&&console.error&&console.error("Tune snippet has been included more than once.");else{o.invoked=!0,o.methods=["init","identify","convert"],o.factory=function(n){return function(){var e=Array.prototype.slice.call(arguments);return e.unshift(n),o.push(e),o}};for(var e=0;e<o.methods.length;e++){var n=o.methods[e];o[n]=o.factory(n)}o.init=function(e){var n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://js.go2sdk.com/v2/tune.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(n,t),o.domain=e}}}();
tdl.init("YOUR TRACKING SERVER DOMAIN")
tdl.convert()
</script>
Remember to replace "YOUR TRACKING SERVER DOMAIN".
The convert function is fully capable of handling goals and conversion parameters. For more information on using the convert function, please visit the Advanced Integration - Convert method
Advanced Integration
The convert method can include any additional conversion parameters you'd like, and the identify method can be passed default and override values for session creation.
Convert method
To pass additional information to the conversion, you can include any of the TUNE conversion parameters, for example adv_sub:
tdl.convert({
'adv_sub': 'example'
})
Goals
To convert on a goal instead of the default endpoint, you can pass either the goal_id or goal_name associated with the goal you'd like to track.
tdl.convert({
'goal_id': '4'
})
tdl.convert({
'goal_name': 'new-registration'
})
Promo Codes
To convert with a promo code on an offer with no advertiser attached, you can simply pass the promo code name to the convert function.
tdl.convert({
'promo_code': 'SUMMERSALE'
})
For offers that have an advertiser attached, include the Advertiser ID found in the promo codes section on the Offer Details Page:
tdl.convert({
'promo_code': 'SUMMERSALE'
'adv_id': 500
})
Identify method
Organic Traffic
In order to get a clear picture of where their traffic is coming from, sometimes you also want to capture organic traffic – that is, traffic that has not been directed from a partner.
The Identify method can be passed default values for session creation. Default values are used to create sessions for users reaching your site organically. It may look something like this:
tdl.identify({
'aff_id': '1002',
'offer_id': '5'
}, {})
The following is the priority the identify method uses when saving or creating a transaction ID:
- Transaction ID passed on query string parameters
- Override values
- Query string parameters
- Default values
Direct Links
Direct links enables you to link directly to a site without redirecting through the TUNE tracking servers. You can use direct links decorated with offer and partner ID values to bring users to your landing page.
When no transaction ID is present on the click URL, the identify method will attempt to generate a transaction ID. As each TUNE transaction ID identifies a specific offer and affiliate pair, the following will need to present in the tracking link:
- aff_id or aff_ref (to identify the referring partner)
- offer_id or offer_ref (to identify the offer)
Multiple TUNE accounts for a single brand
In cases where a brand is working with multiple different TUNE accounts, the TUNE Javascript Tracking can support all of them at the same time. In these cases, the setup is as follows.
The 'init' call should reflect all of the partners the brand is working with. This is how the initialization call should be structured in these cases:
tdl.init({
'networkID1': 'https://test1.go2cloud.org',
'networkID2': 'https://test2.go2cloud.org'
})
The Network ID for is available within a TUNE account under Company > My Account > Network Details
When promoting an offer with this setup, the partner needs to ensure that they are including the Network ID in the Offer URL. Example Default Offer URL:
https://offer.brand.com?transaction_id={transaction_id}&network_id=networkID1
Troubleshooting
Setup issues
- Make sure your network id is not capitalized
- Make sure the domain is using https
Browser issues
- Make sure your postback domain is not blocked by ad blocker (we recommend not using custom domains including words such as "affiliate")
- Make sure the postback is not blocked by your sites Content-Security-Policy
Additional Information
For more information on how you can start using Javascript Tracking, please see our developer documentation.