Tracking Integration

Please see our most up to date, standalone article here:

AvantLink Technical Integration Guide


Overview

The AvantMetrics tracking is AvantLink’s standard tracking implementation. In addition to tracking conversions it allows clients to quickly and easily implement AvantMetrics services if desired.

There are a couple steps required for integrating the tracking:

Adding a reference to the site-wide tracking JavaScript library

Calling the order tracking component when orders are placed

Adding a reference to the site-wide tracking JavaScript library

AvantMetrics tracking functions similar to many web analytics packages in that it uses a small JavaScript library and a combination of first- and third-party cookies to monitor visitors as they move through your site. In order for this monitoring to work properly, the JavaScript library should be referenced on every page of your site, as in the following:

<script type="text/javascript">
(function() {
var avm = document.createElement('script'); avm.type = 'text/javascript'; avm.async = true;
avm.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.avmws.com/[SITE_ID]/';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(avm, s);
})();
</script>

Pay special attention to the “[SITE_ID]” marker in the above: this must be filled in with your 7-digit website ID, which begins with the number 10. For example:  1010048. Contact your account representative or support if you need help obtaining this ID.

It is recommended that this JavaScript be included immediately before the closing BODY tag of each page on your site.

Calling the order tracking component when orders are placed

For order information to be sent to AvantMetrics a series of variables must be populated PRIOR TO calling the site-wide JavaScript library. The information to supply comes in two main parts: an order summary record (required) specifying the order id/number and dollar amount total, and order item details (optional, but recommended) that specify the details of what items were included in the order. Following is a template for how to output the order information:

<script type="text/javascript">
var _AvantMetrics = _AvantMetrics || [];
_AvantMetrics.push(['order',{ order_id:'[ORDER_ID]', amount:'[ORDER_AMOUNT]', state:'[BILLING_STATE]', country:'[BILLING_COUNTRY]' }]);
_AvantMetrics.push(['item',{ order_id:'[ORDER_ID]', parent_sku:'[ITEM_PARENT_SKU]', variant_sku:'[ITEM_VARIANT_SKU]', price:'[ITEM_PRICE]', qty:'[ITEM_QUANTITY]' }]);
</script>

Again, it cannot be emphasized enough that the order information must be included in your page BEFORE the reference to the AvantMetrics site-wide tracking JavaScript library. It is recommended that the order data be output in the HEAD element of your pages, while including the site-wide JavaScript right before the closing BODY tag of your pages.

Please Note: If you are using a Tag Management system to handle your Order Confirmation scripts, please reference our support article regarding how to integrate with a Tag Manager.

In the sample template above, there are a number of variable markers; these must be replaced with the actual values corresponding to the order. Those substitutions are as follows:

[ORDER_ID] – should be replaced with the actual id/number that uniquely identifies this order.

[ORDER_AMOUNT] – should be replaced with the dollar amount total for this order, not including tax or shipping and handling fees. Should be formatted as a decimal number without dollar sign or commas. It should be noted that the order amount must be above 0 for that sale to record as an affiliate sale.

By default, all currency values should be supplied as US dollars (USD) for the US network, Canadian dollars (CAD) for the CA network, and Austrialian dollars (AUD) for the AU network.

[BILLING_STATE] – should be replaced with the U.S. state associated with the order’s billing address; preferably the standard (e.g. U.S. Postal Service) 2-letter abbreviation for the state.

[BILLING_COUNTRY] – should be replaced with the country associated with the order’s billing address; preferably the 2- or 3-letter ISO 3166 country code.

Note that the above template represents the minimal required elements for order tracking: “order_id”, “amount”, “state”, “country”. A number of additional, optional pieces of information can be supplied and may allow for additional functionality within your affiliate network(s):

“ecc” – Exclusive coupon code(s) can be supplied if one or more coupon codes were used for the order. This element isn't required, but it is encouraged. This data provides the capability of merchants to associate a coupon code to particular affiliates.

“ac” – Custom affiliate commission can be supplied for solutions that require highly customized logic for computing the commission due for a particular order.

“nc” – Custom network commission can be supplied for solutions that require highly customized logic for computing the commission due for a particular order.

“tax” – Can be used to specify the dollar amount (in decimal format, no dollar sign, no commas) of tax charged for this order.

“shipping” – Can be used to specify the dollar amount (in decimal format, no dollar sign, no commas) of shipping and handling fees charged for this order.

“currency” – Can be used to specify the currency type to be used for this transaction, if different than the default; must be specified as a 3-letter ISO 4217 currency code.

“new_customer” – Can be used to specify whether the customer is new or returning; must be “Y” or “N”. While this isn't a required element we recommend that this value be provided as it allows for merchants to give a bump to affiliates on sales from new customers, thus encouraging affiliates to market to new customers.

For the item detail records it should first be noted that while only one item is shown in the above example template, additional item lines can be output as necessary to properly indicate the contents of the order. In other words there should be just as many lines of JavaScript for “item” records, as there are different items in the order. As with the order summary record, there are variable substitutions that must be made to the above template:

[ORDER_ID] – should be replaced with the actual id/number that uniquely identifies this order.

[ITEM_PARENT_SKU] – should be replaced with the parent-level unique identifier (commonly called a SKU) for each item. This SKU should agree with any product SKUs provided in the product datafeed for your program.

[ITEM_VARIANT_SKU] – should be replaced with the variant-level (a.k.a. child-level) unique identifier for each item. This identifier is more specific (generally down to the size/color/style level) than the parent-level SKU mentioned above. If variant-level details are included in the product datafeed, then this value can/should agree with the individual variant-level identifiers.

[ITEM_PRICE] – should be replaced with the per-item price (in decimal format, no dollar sign, no commas) for each item.

[ITEM_QUANTITY] – should be replaced with the number representing how many of this particular item were ordered. If this product doesn't have an associated variant sku please leave this field blank, as if our system finds a blank variant_sku value the parent SKU will be used.

Complete Example

Following is a fully populated example for a confirmation page that supplies order tracking data (for a 3-item order).Remember though that the [SITE_ID] value used in this example will be different than your own. This example is provided for reference only, and should not be copied directly.

<html>
<head>
...
<title>Sample Order Confirmation</title>
...
<!-- Here we specify the order information to be tracked -->
<script type="text/javascript">
var _AvantMetrics = _AvantMetrics || [];
_AvantMetrics.push(['order',{ order_id:'567', amount:'95.00', state:'UT', country:'USA', new_customer:'N' }]);
_AvantMetrics.push(['item',{ order_id:'567', parent_sku:'abcde', variant_sku:'abcde-sm', price:'20.00', qty:'2' }]);
_AvantMetrics.push(['item',{ order_id:'567', parent_sku:'efghi', variant_sku:'efghi-blue', price:'10.50', qty:'1' }]);
_AvantMetrics.push(['item',{ order_id:'567', parent_sku:'jklmn', variant_sku:'345687319', price:'22.25', qty:'2' }]);
</script>
</head>
<body>
...
Sample Order Confirmation Page
...
<!-- Here we reference the AvantMetrics site-wide JavaScript library -->
<script type="text/javascript">
(function() {
var avm = document.createElement('script'); avm.type = 'text/javascript'; avm.async = true;
avm.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.avmws.com/1234/';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(avm, s);
})();
</script>
</body>
</html>

Once the tracking pixel has been placed a test should be ran to ensure affiliate orders are being sent properly. If the checkout process includes multiple payment methods a test should be ran with each of these payment methods to ensure the tracking pixel is being fired correctly for each method.

Tracking Suppression

Proper integration with AvantMetrics requires calling the tracking component for every order placed through your site. We recognize however, that there may be times when proprietary business logic makes it desirable to suppress / deactivate the AvantMetrics tracking component. An example of this might be with in-house deduplication between multiple affiliate networks or multiple advertising channels; custom logic may indicate that a given order should not be attributed to an AvantLink Affiliate, which might occur if the AvantMetrics tracking were called normally. (Incidentally, AvantMetrics has functionality for this type of problem built into it, obviating the necessity of constructing this logic in-house. Nevertheless…) In such cases rather than not call the AvantMetrics tracking at all, an additional parameter should be added to the order information, namely:

track:'N'

or, in more context:

<script type="text/javascript">
var _AvantMetrics = _AvantMetrics || [];
_AvantMetrics.push(['order',{ track:'N', order_id:'[ORDER_ID]', amount:'[ORDER_AMOUNT]', state:'[BILLING_STATE]', country:'[BILLING_COUNTRY]' }]);
...
</script>

Utilizing this parameter will allow us to retain all functionality for verifying that tracking is properly functioning, while still ensuring that no affiliate commissions are triggered as a result of this order.

 

If you have any questions please contact integration@avantlink.com for help.

 

Have more questions? Submit a request
Powered by Zendesk