Integration via tracking code

  • Mise à jour

Note
If your company belongs in the financial sector (banks, insurance companies, and other financial organizations), go to the article "Integration via tracking code for financial programs."

Purpose of the tracking code

The tracking code is a JavaScript code that you are to place on your website.

Tracking code tracks data about users’ purchases and leads on your website and sends it to the Admitad statistics. When the tracking code is triggered, the Admitad server receives a request with information about this action (order ID, order amount, etc.).

integration-via-tracking-code.png

Besides, the tracking code is used for order deduplication and cross-device tracking.

Note:

  • Insert the code in the <head> tag before all other scripts, otherwise, a user may close the page before the script is triggered.
  • We do not recommend installing it in Google Tag Manager (GTM), as it may be blocked by popular ad blockers. This can lead to losses of orders, discrepancies in the analytics, and problems with verifications.
  • When the site is updated, it is necessary to check out that the code has not been deleted and continues working.
  • If there is a mobile website or a mobile app, quick order forms, or 1-click order forms, make sure that they are also integrated.

To get started with Admitad, provide a link to your website with all GET parameters and UTM parameters you need.

Link example
https://site.com/?utm_source=admitad&utm_medium=cpa

This link will be used for generating affiliate links for our publishers. In the future, they will place affiliate links on their ad spaces and drive traffic to your website.

You can provide several links, but only one of them will be set as a default link of your program.

Setup of the tracking code

To set up the tracking code, insert the script to all pages of your website.

During integration, we will send you the {your_campaign_code} value.

Expand
<script src="https://www.artfut.com/static/tagtag.min.js?campaign_code={your_campaign_code}" async onerror='var self = this;window.ADMITAD=window.ADMITAD||{},ADMITAD.Helpers=ADMITAD.Helpers||{},ADMITAD.Helpers.generateDomains=function(){for(var e=new Date,n=Math.floor(new Date(2020,e.getMonth(),e.getDate()).setUTCHours(0,0,0,0)/1e3),t=parseInt(1e12*(Math.sin(n)+1)).toString(30),i=["de"],o=[],a=0;a<i.length;++a)o.push({domain:t+"."+i[a],name:t});return o},ADMITAD.Helpers.findTodaysDomain=function(e){function n(){var o=new XMLHttpRequest,a=i[t].domain,D="https://"+a+"/";o.open("HEAD",D,!0),o.onload=function(){setTimeout(e,0,i[t])},o.onerror=function(){++t<i.length?setTimeout(n,0):setTimeout(e,0,void 0)},o.send()}var t=0,i=ADMITAD.Helpers.generateDomains();n()},window.ADMITAD=window.ADMITAD||{},ADMITAD.Helpers.findTodaysDomain(function(e){if(window.ADMITAD.dynamic=e,window.ADMITAD.dynamic){var n=function(){return function(){return self.src?self:""}}(),t=n(),i=(/campaign_code=([^&]+)/.exec(t.src)||[])[1]||"";t.parentNode.removeChild(t);var o=document.getElementsByTagName("head")[0],a=document.createElement("script");a.src="https://www."+window.ADMITAD.dynamic.domain+"/static/"+window.ADMITAD.dynamic.name.slice(1)+window.ADMITAD.dynamic.name.slice(0,1)+".min.js?campaign_code="+i,o.appendChild(a)}});'></script>

The code in the onerror attribute prevents erroneous blocking of the script loading by ad blockers and antivirus software.

Setup of the order data transmission

Transfer of order information

If you work with one of the major affiliate networks, the Admitad tracking code can independently collect order information using already configured integration. Go to the Order deduplication section to see examples for other affiliate networks. Skip this section, if you have found your affiliate network in the examples.

After you insert the script to all pages, set up the transfer of order data. To do this, add the code from the example below to the thank you page.

Example of the code for one order with several items

Hereinafter we mark the code that must be used for every order item with a special comment.

{{value}} — replace it with a value of a real variable.

Expand
<script type="text/javascript">
ADMITAD = window.ADMITAD || {};
ADMITAD.Invoice = ADMITAD.Invoice || {};
ADMITAD.Invoice.broker = 'adm';  // deduplication parameter (for Admitad by default)
ADMITAD.Invoice.category = '1';  // action code (defined during integration)

var orderedItem = [];  // temporary array for product items
	
// repeat for every product item in the cart
orderedItem.push({
	Product: {
		productID: '{{product_id}}',  // internal product ID (not more than 100 characters, the same as in your product feed)
		category: '1',  // tariff code (defined during integration)
		price: '{{price}}',  // product price
		priceCurrency: 'RUB',  // currency code in the ISO-4217 alfa-3 format
	},
	orderQuantity: '{{quantity}}',  // product quantity
	additionalType: 'sale'  // always sale
});
ADMITAD.Invoice.referencesOrder = ADMITAD.Invoice.referencesOrder || [];
// adding items to the order
ADMITAD.Invoice.referencesOrder.push({
	orderNumber: '{{order number}}',  // internal order ID (not more than 100 characters)
	orderedItem: orderedItem
});
// Important! If order data is loaded via AJAX, uncomment this string.
// ADMITAD.Tracking.processPositions();
</script>

Be sure to find orders by this orderNumber in your CRM, as it will be used for verifications in the future.

Example of the code for several orders

Below is an example of the code for orders that are added sequentially. We give this example, so it is easier for you to understand what the code must look like. However, when you insert the code on your website, we recommend to put it in a loop.

Expand
<script type="text/javascript">
ADMITAD = window.ADMITAD || {};
ADMITAD.Invoice = ADMITAD.Invoice || {};
ADMITAD.Invoice.broker = 'adm';  // deduplication parameter (for Admitad by default)
ADMITAD.Invoice.category = '1';  // action code (defined during integration)
/* adding the first order */
	
var orderedItems1 = [];  // temporary array for product items
	
// repeat for every product item in the cart
orderedItems1.push({
	Product: {
		productID: '{{product_id}}',  // internal product ID (the same as in your product feed)
		category: '1',  // tariff code (defined during integration)
		price: '{{price}}',  // product price
		priceCurrency: 'RUB',  // currency code in the ISO-4217 alfa-3 format
	},
	orderQuantity: '{{quantity}}',  // product quantity
	additionalType: 'sale'  // sale type
});
ADMITAD.Invoice.referencesOrder = ADMITAD.Invoice.referencesOrder || [];
// adding items to the order
ADMITAD.Invoice.referencesOrder.push({
	orderNumber: '{{order number}}',  // internal ID of the first order
	orderedItem: orderedItems1
});

/* adding the second order */

var orderedItems2 = [];	// temporary array for product items

// repeat for every product item in the cart
orderedItems2.push({
	Product: {
		productID: '{{product_id}}',	// internal product ID (the same as in your product feed)
		category: '1',	// tariff code (defined during integration)
		price: '{{price}}',	// product price
		priceCurrency: 'RUB',	// currency code in the ISO-4217 alfa-3 format
	},
	orderQuantity: '{{quantity}}',	// product quantity
	additionalType: 'sale'	// sale type
});
ADMITAD.Invoice.referencesOrder = ADMITAD.Invoice.referencesOrder || [];
// adding items to the order
ADMITAD.Invoice.referencesOrder.push({
		orderNumber: '{{order number}}',	// internal ID of the second order
		orderedItem: orderedItems2
});
// Note! If the data of an Admitad order are loaded via AJAX, uncomment this block of code.
// ADMITAD.Tracking.processPositions();
</script>

Setting up order data transfer when using AJAX or a 1-click ordering

If the data of an Admitad order are loaded via AJAX or if you implement 1-click ordering, add the script below right after the order data collection code. You can see an example of its use above in the "Note" string.

<script type="text/javascript">
	ADMITAD.Tracking.processPositions();
</script>

Setting up data transfer of unique promo codes

Unique promo codes are promo codes that are linked to a specific publisher. Learn more about them here.

To use unique promo codes:

1. Make sure there is a coupon entry field on the checkout page

2. Enter the unique promo code from the checkout page to the parameter discountCode.

Example of a code
ADMITAD.Invoice.referencesOrder = ADMITAD.Invoice.referencesOrder || [];
// adding items to the order
ADMITAD.Invoice.referencesOrder.push({
	orderNumber: '{{order number}}',  // internal order ID (not more than 100 characters)
	discountCode: '{{promocode}}',  // unique promo code
	orderedItem: orderedItem
});

3. Transferring the unique promo code order information always set up “adm” value to the deduplication parameter as the order belongs to Admitad.  

ADMITAD.Invoice.broker = 'adm';

Attribution logic

Show
integration-via-tracking-code_Cy5WO5x.png




4. Transferring a regular order (not one with a unique promo code), use the standard deduplication setting.

Order deduplication

If you work only with Admitad, use the default value of the deduplication parameter and skip this step.

If you work with more than one paid source, enable order deduplication on your end so that order information gets transferred in accordance with Last Paid Click:

  1. Inform the employee of the Admitad tracking department which GET parameter you are going to use for deduplication. By default, the parameter is not added.
  2. Create a deduplication cookie with the source value. Cookie must be stored during the entire period specified in your agreement (the default period is 90 days).
  3. Define the value of the deduplication parameter from the cookie when transmitting order data in the ADMITAD.Invoice.broker parameter. This way we can define which source the order belongs to. For Admitad orders, the value of the deduplication parameter must be adm. Orders with the values of other paid sources will not be created. Orders with an undefined source will be created if a user visited the website by clicking an Admitad affiliate link on another device or browser during the cookie lifetime.

Example of the code where the cookie is used to store the click source

Expand
<script type="text/javascript">
// name of the cookie that stores the source
// change if you have another name
var cookie_name = 'deduplication_cookie';
// cookie lifetime
var days_to_store = 90;
// expected deduplication_cookie value for Admitad
var deduplication_cookie_value = 'admitad';
// name of GET parameter for deduplication
// change if you have another name
var channel_name = 'deduplication_channel';
// a function to get the source from the GET parameter
getSourceParamFromUri = function () {
	var pattern = channel_name + '=([^&]+)';
	var re = new RegExp(pattern);
	return (re.exec(document.location.search) || [])[1] || '';
};

// a function to get the source from the cookie named cookie_name
getSourceCookie = function () {
	var matches = document.cookie.match(new RegExp(
		'(?:^|; )' + cookie_name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + '=([^;]*)'
	));
	return matches ? decodeURIComponent(matches[1]) : undefined;
};
// a function to set the source in the cookie named cookie_name
setSourceCookie = function () {
	var param = getSourceParamFromUri();
	if (!param) { return; }
	var period = days_to_store * 60 * 60 * 24 * 1000;	// in seconds
	var expiresDate = new Date((period) + +new Date);
	var cookieString = cookie_name + '=' + param + '; path=/; expires=' + expiresDate.toGMTString();
	document.cookie = cookieString;
	document.cookie = cookieString + '; domain=.' + location.host;
};
// set cookie
setSourceCookie();
// define a channel for Admitad
if (!getSourceCookie(cookie_name)) {
	ADMITAD.Invoice.broker = 'na';
} else if (getSourceCookie(cookie_name) != deduplication_cookie_value) {
	ADMITAD.Invoice.broker = getSourceCookie(cookie_name);
} else {
	ADMITAD.Invoice.broker = 'adm';
}
</script>

Example of deduplication parameters of other affiliate networks

Expand
AWIN.Tracking.Sale.channel = 'adm';	// http://wiki.awin.com/index.php/Advertiser_Tracking_Guide/De-duplication
window.criteo_q.push({ event: 'trackTransaction', deduplication: 'adm', <...>);	// https://support.criteo.com/hc/fr-fr/articles/205573701-Deduplication-Parameter

If you use the tracking code of another affiliate network to integrate with Admitad, after you remove it, the integration with Admitad will be broken as well. Please inform us before removing the code.

Cross-device tracking

Cross-device tracking allows publishers to get reward for orders even if users use several devices. This will make the program more appealing to publishers who, for instance, drive mobile traffic.

The function is enabled by default. When users visit the advertiser’s site, we create their unique anonymous profile to collect the relevant data. When a user makes an order, we cross-reference the data collected within their profile and create an order for them in case they already have an admitad_uid. This function works best with the order deduplication set up. To help Admitad identify users precisely, transmit their unique identifiers, i.e. email addresses or their website logins. Unique identifiers have priority over anonymous profiles: if you transmit accountId, then the request to Admitad does not contain the data of an anonymous profile, but your value is used.

Insert the snippet below to the pages where the user email or login are known.

<script type="text/javascript">
   ADMITAD = window.ADMITAD || {};
   ADMITAD.Invoice = ADMITAD.Invoice || {};
   ADMITAD.Invoice.accountId = 'customer@email.ru';  // user e-mail or login in your system
</script>

Admitad does not store the value of this parameter and does not transmit it unsecured.

The value of the variable is irreversibly hashed in Sha256(ADMITAD.Invoice.accountId + salt), and is then used by Admitad as a unique identifier of the user’s orders.

This identifier will attribute the order to a certain user, even if the user first opens an Admitad affiliate link on their PC, and then makes the order from a mobile device on their way to work. The order will not be lost; it will still be registered in the Admitad statistics.

Tracking testing

1. Make sure that you have set up the tracking code and order data transmission. Note that if you have a mobile website, quick order forms, or 1-click order forms, they should also be integrated.

For this purpose, you can use the Chrome extension TagTag Check. It will check if you have installed all the necessary scripts, parameters, and cookies on your website pages, including the thank you page.

To install the extension, follow this link. Then go to the website and open the extension. If the integration is configured properly, all fields will be ticked. If one of the required elements is missing or incorrect, it will be marked with Integration via tracking code 3, and in the Details column, there will be an error description.

integration-via-tracking-code_ywyiLzr.png

To check if you have set up the integration on the thank you page, go to it and click the toggle button.

integration-via-tracking-code_tqOYKjo.png

2. After that contact the Admitad tracking department and request a test link.

If your program has several actions (e.g. “Registration” and “Paid order”), you need to test each of them.

3. Follow the test link to your website. Check if the address bar contains all required GET parameters and UTM parameters.

4. Perform an action on the website. For example, buy something.

5. While you are on the thank you page, open the TagTag Check extension and select the Tracking requests tab. Make sure that the request has been sent.

6. If the tracking is set correctly, the action will appear in the Admitad statistics (account — Reports — on actions). Check if the action name, action ID, and order amount are correct.
integration-via-tracking-code_4i05Ipv.png

In case you run the tests successfully, inform the Admitad specialists about it. They will prepare the program for launch.

Problems that can arise during testing

If the action has not appeared in the statistics, probably, you have made a mistake when installing and setting up tracking code.

Problem How to fix it
The script does not work. No requests from the script on the Network browser tab. The script is installed incorrectly.
Follow the instructions of the section Setting the tracking code.
The script does not work. There are errors in the browser console. Follow the instructions of the section Setting up order data transmission.
Check the syntax of JavaScript on the thank you page
The script is triggered. There are no errors in the browser console. The order has not appeared in the statistics. The value of the campaign_code parameter is invalid or missing.
Check the value of campaign_code with the Admitad specialist.
The script is triggered. There are no errors in the browser console. The value of the campaign_code parameter is correct. The order has not appeared in the statistics. To identify the error, go to the request log (Tools Request log). The error text is specified in the Result field. Correct the error and retest.
Guide on the Request log is available here.
The script is triggered. There are no errors in the browser console. The value of the campaign_code parameter is correct. No errors in the Request log section. The order has not appeared in the statistics. There is a log delay on the Admitad side, wait an hour and then check again.
The script is triggered. There are no errors in the browser console. The value of the campaign_code parameter is correct. No errors in the Request log section. The order has not appeared in the statistics within an hour. Ask the Admitad specialist for help.

Cet article vous a-t-il été utile ?