Getting Started with TUNE Javascript Tracking

The TUNE Javascript Tracking method offers client-side functionality for session storage and conversions to Advertisers. By utilizing TUNE's Javascript Tracking, you'll have the accuracy of server-side postbacks with the setup effort of client-side pixel tracking. This tutorial will walk you through the steps of setting up your Offer, adding the TUNE Javascript to a page to start & store sessions, and then post a conversion.

Before you Begin

This tutorial assumes you already have your Offer set up. For additional information on creating your first Offer, please visit our article on Creating an Offer.

There are a few steps you'll need to go through before using TUNE's Javascript Tracking to interact with an Offer.

The TUNE Javascript utilizes "server-side" postbacks. In order for the TUNE Javascript Tracking to work, you'll need to set the attribution method of your offer to Server Postback w/Transaction ID.

In the Offer's default offer URL, you'll want to ensure you're forwarding the transaction_id as a parameter on the URL.

For example, if you're directing traffic to:

You'll want to ensure the transaction_id is being appended like so:{transaction_id}

Step 1: Adding the Snippet

Adding Tune Javascript Tracking is simple. Paste the code below to the head of any site to add the Javascript functionality:

!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;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="";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(n,t),o.domain=e}}}();

After you paste it, you'll need to replace "YOUR TRACKING SERVER DOMAIN" with your network's tracking server domain. Your tracking server domain 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:

The above code will load additional methods asynchronously as to not affect your page's load times. As soon as the code has loaded, you can then call other methods to either track a session or post a conversion. You can do so by calling either of the other two methods: identify or convert.

Supporting Multiple Networks with the Same TUNE Javascript Tracking

In cases where an advertiser is working with multiple different TUNE networks, the TUNE Javascript can support all of them at the same time.  In these cases, the setup is as follows:

For the Advertiser

The 'init' call for the TUNE JS should reflect all of the partners the advertiser is working with.  This is how the initialization call should be structured in these cases:

 '[Network ID For Network A]': '[Tracking Domain for Network A]',
 '[Network ID For Network B]': '[Tracking Domain for Network B]',

The Network ID for a network is available within a TUNE account on the Company > My Account, within the 'Network Details' area.

  'testnet1': '',
  'othernet2': ''

For the Network

In cases where a network is working with an advertiser using the TUNE Javascript Tracking across multiple networks, they need to ensure that they're including their Network ID in the Offer URLs used for that advertiser.  This Network ID is the same ID noted in the Company > My Account page as 'Network ID'.  The Network ID should be included at the end of the Offer URL as follows:

An example Default Offer URL would be as follows, with the additional parameter highlighted in bold:{transaction_id}&network_id=hasoffersdemo

Step 2: Identify

Note: The following section assumes you've installed the TUNE Javascript Tracking base code on your page as described above.

The identify method is called when you want to store or generate a user's session. If you're familiar with our traditional tracking links, this method largely corresponds to a "click".

At its more basic, the identify method can be called like so:


That will pull the transaction_id parameter from the URL's query string and store it in the user's browser's local storage.

We recommend using a backend template or theme to help inject the call into the footer or header of every page of your site a user might first visit. That way, no matter which page or product the user first lands on, they will always have their session stored.

The identify function can also be used to generate a session before storage by passing optional parameters to the method itself. For more information on using the Identify function, please visit the SDK method reference.

Step 3: Convert

The convert method enables you to record a conversion using the user's currently stored session. Since the session's transaction ID has the associated affiliate and offer IDs, you do not need to include these when calling the convert method.

At its most basic, the convert method is simply:


The convert function is fully capable of handling goals and conversion parameters. Including these optional fields will allow you to record additional information during conversion. If we wanted to record a goal conversion with an additional parameter included, an example would be:

 'goal_name': 'purchase',
 'adv_sub': 'abc123'

You can also pass the ID of a goal in a similar manner:

 'goal_id': '4',
 'adv_sub': 'abc123'

For more information on using the convert function, please visit the SDK method reference.

Next Steps

This was a brief introduction to storing sessions and tracking conversions. To learn more about what's possible with TUNE's Javascript Tracking, please visit the SDK method reference.

Have a Question? Please contact [email protected] for technical support.