Implementing a deduplication script

If you use multiple tracking solutions you can automate the deduplication process so you avoid paying double commissions. This deduplication solution will attribute the transaction to the latest click.

It works as follows:

  1. A source parameter is added to every Publisher link with a unique identifier for each tracking solution.

  2. A script on your website retrieves this parameter and sets a cookie with the unique identifier.

  3. Based on the cookie, only the tracking pixel that corresponds with the unique identifier will be loaded on the success page(s) of your Offer.

1. Adding the parameter

The first step is to pass the tracking solution for the traffic as a parameter in the target URL. It’s important you do this for all you tracking solutions. In our platform you can add this parameter as a default target URL extension of the Offer. You do this in the tracking tab when creating or editing an Offer:

The name of the parameter (source in this example) can be anything you want, as long as you use the same parameter for all tracking solutions. The value of the paramter (tc in this example) should be unique for each tracking platform.

2. Place the script on your website

The second step is to retrieve the value from the target URL and place a deduplication cookie with the value of the parameter. To achieve that, the following code should be placed on every landings page of your website:

(function() {
    /* Configuration */
    var paramName = 'source';
    var cookieName = 'source';

    /* Functions */
    function getParameterByName(name, url) {
        name = name.replace(/[[]]/g, "\$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';

        return decodeURIComponent(results[2].replace(/+/g, " "));

    function setCookie(key, value) {
        document.cookie = key + '=' + value;

    setCookie(cookieName, getParameterByName(paramName, window.location.href));

Before you place the script on your website, make sure the paramName and cookieName variables in the configuration part of the script are set to the names you are using (‘source’ in this example).

3. Modify the success page

The last step is to modify the success page(s) so that only the tracking pixel that corresponds with the unique identifier of the cookie will be fired.

This step assumes you are implementing 3rd-party cookie tracking. If you are implementing 1st-party cookie tracking or postback tracking similar logic can be implemented before doing the server-to-server call.

The following code should be placed on your success page(s):

(function () {
    /* Configuration */
    var cookieName = 'source';
    var pixel = {
        tc: '<img src="{offer_sid}&event_sid={event_sid}&id={id}" alt="" width="1" height="1" border="0" />',
        abc: '<!-- replace with abc tracking pixel -->',
        xyz: '<!-- replace with xyz tracking pixel -->'

    /* Functions */
    function getCookie(key) {
        var value = "; " + document.cookie;
        var parts = value.split("; " + key + "=");
        if (parts.length == 2) return parts.pop().split(";").shift();

    function setPixel(name, pixel) {
        var div = document.createElement('div');
        if (name in pixel) {
            div.innerHTML += pixel[name];
        } else {
            for (var key in pixel) {
                if (pixel.hasOwnProperty(key)) {
                    div.innerHTML += pixel[key];

    setPixel(getCookie(cookieName), pixel);

Before you place the script on your website, make sure to include all the unique identifiers for the tracking solutions and the corresponding pixels in the configuration part of the script. Note that the Target Circle pixel is already included, but you still have to replace all the parameter values.

Boost your affiliate program

Download our free whitepaper for insights into 2020’s top affiliate marketing trend: self-service affiliate programs

© 2020 Target Circle AS | Terms & Privacy | Cookie preferences | Email

Learn the 2020’s Top Affiliate Marketing Trends