Javascript SDK Method Reference

The TUNE Javascript SDK offers a simple way for managing sessions and conversions without cookies or pixels.

Getting Started

If you haven't yet, please check out our Javascript SDK Getting Started guide which will guide you through adding the Javascript SDK's snippet to your page.

Identify

The identify method is how you generate and store a user's session, represented by a transaction ID. If you're familiar with traditional TUNE tracking links, this is largely synonymous with a "click".

The identify method:

tdl.identify([defaults], [overrides]);

The following parameters can be passed to the identify method:

defaults optional Object A dictionary of tracking link parameters to be included on every click. Parameters passed as defaults will be overwritten if the same parameter is included as part of the URL's query string.
overrides optional Object A dictionary of tracking link parameters to be included on every click. Parameters passed as overrides will overwrite the same parameter if it was included as a default or as part of the URL's query string.

By default, the identify method will only parse query string parameters. If a transaction ID is included on the URL (e.g. the user is coming through TUNE's tracking servers and being redirected with a transaction ID appended), the transaction ID will be stored inside the user's browsers and you're ready to install the convert method on another page.

However, when no transaction ID is present on the URL, the init 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:

  1. aff_id or aff_ref (to identify the referring partner)
  2. offer_id or offer_ref (to identify the offer)

When using the identify method to generate a transaction ID, any other TUNE tracking link query string parameters (e.g. aff_sub, source) will also be included in the session creation. In addition to this, there are two other ways to pass parameters when creating a session.

Default Values

The identify method can also be set to set default values for session creation. These will be used to create a session regardless of whether any query string parameters were passed or not. If the same parameter is set as a default and is also passed as a query string parameter, the passed parameter will take precedence over the value set as default. Default values can be used to create sessions for users reaching your site 'orgnically'. An identify method with defaults for organic traffic may look something like this:

tdl.identify({
  'aff_id''1002',
  'offer_id''5'
}, {})

Override Values

Like default values, override values are parameters passed directly to the identify function. However, unlike default values, they will overwrite any parameters parsed from the URL's query string. Building off the example above, imagine if we wanted to include a reference to the exact page that the user first arrived at inside of the aff_sub parameter. It would be:

tdl.identify({
  'aff_id''1002',
  'offer_id''5'
}, {
  'aff_sub''SKU98919'
})

Parameter Priority

The following is the priority the identify method uses when saving or creating a transaction ID:

  1. Transaction ID passed on query string parameters
  2. Override values
  3. Query string parameters
  4. Default values

Session Priority

Identify will check to see if a transaction ID has been stored before attempting to generate a new one, so a user browsing different pages of a website won't constantly keep generating new transaction IDs. If a user comes from another referral link (containing a new affiliate or offer value), the new transaction ID will replace the old one. Transaction IDs generated only with default values will always be overwritten if enough information is provided, but will never overwrite ones generated with query string parameters.

Convert

tdl.convert([conversion_data]);

The following parameters can be passed to the convert method:

conversion_data optional Object A dictionary of conversion link parameters to be included on the conversion, including a

Optionally, you can also include any additional parameters you'd like to include on the conversion by passing them to the convert method. An example of this is below:

tdl.convert({
'adv_sub''example'
})

Goals

To convert on a goal instead of the default endpoint, you merely need to include the goal_id associated with the goal you'd like to track.

tdl.convert({
'goal_id''4'
})
Have a Question? Please contact support@tune.com for technical support.