Custom cart tracking

 

Updated for Safari ITP 2.0 Mitigation

 

Last Modified: August 1st, 2018

Contents

1.       Overview... 3

2.      Conversion Tracking Installation Instructions. 4

2.1.        Understand the basic tracking tag/pixel code setup and purpose. 4

2.2.       Product Level Tracking.. 5

2.3.       Coupon Code Tracking.. 5

2.4.       Customer Status Tracking.. 5

2.5.       StoresConnect. 6

2.6.       Situational Tracking Parameters. 6

2.7.       First-party cookie tracking (required, Fall 2018). 7

2.7.1.          Server-side PHP example. 7

2.7.2.         Client-side JavaScript example. 7

2.7.3.         Google Tag Manager example. 7

2.8.       Install the tracking pixel code. 8

2.8.1.         Find the file, template, or section of your cart admin that allows you to customize the site’s checkout "thank-you" receipt page. 8

2.8.2.        Place the tracking pixel code on the checkout "thank-you" receipt page. 9

3.      Master tag Installation Instructions (required, Fall 2018). 10

3.1.        Understand the "master" tag’s setup and purpose. 10

3.2.       Add the master tag tracking code above. 10

3.2.1.          Find the file, template, or section of your cart admin that allows you to place code that will be included on every page of the site. 10

3.2.2.         Place the master tag code so that it appears on every page of your site. 11

4.      Testing.. 13

4.1.        Click the test link. 13

4.2.       Run a test purchase. 13

4.3.       Check that the test purchase tracked. 13

4.3.1.         Click Reports and then click Transaction Details from the drop-down menu. 13

4.3.2.        Filter the report for Affiliate ID 178 using the panel on the left. 14

4.3.3.        The filtered view should now show your test purchase as an entry with today’s date. 14

4.3.4.        If the order tracked successfully….. 15

4.3.5.        If the order does not show up in the Transaction Details Report….. 15

1.    Overview

ShareASale’s tracking involves two "tags" or "pixels" which are snippets of code installed specifically on the checkout "thank-you" receipt page and in the header of every other site page. The first tag is for tracking conversions (i.e. sales) and the second for assisting with Affiliate click attribution accuracy in certain browsers, respectively.

ShareASale retrieves the following data about Affiliate-referred orders where possible:

1.       Amount – order subtotal after discounts but before taxes and shipping

2.       Tracking – order ID of the customer

3.       Coupon Code – the discount code used in the order, if any

4.       Skulist – a comma-separated list of SKUs for the products purchased

5.       Pricelist – a comma-separated list of item prices for the SKUs in the same order

6.       Quantitylist – a comma-separated list of the quantities of each SKU

7.       Newcustomer – whether the customer was new (1), old (0), or unknown (no value)

8.       Currency – the three letter ISO-4217 currency code for the currency used by the customer, e.g. EUR for Euros, GBP for British Pounds, USD for US Dollars, etc.

2.    Conversion Tracking Installation Instructions

2.1.                Understand the basic tracking tag/pixel code setup and purpose.

A sale event is a "conversion" where any money changes hands. These can be any sort of purchase or account signup that results in a transfer of funds on your site.

This section covers the anatomy of the ShareASale sale tracking pixel. The location on your site to install the tracking is discussed later in section 2.7.

The most basic pixel configuration for tracking these events allows ShareASale to record each with a separate tracking ID and order amount. A basic sale tracking pixel will resemble the example code below (a 1x1 "pixel"-sized <img> and secondary <script> underneath):

<img id="_SHRSL_img_1" src="https://www.shareasale.com/sale.cfm?tracking=OrderID&amount=AA.BB&merchantID=XXXXX&transtype=sale" width="1" height="1">

<script defer async type="text/javascript" src="https://shareasale-analytics.com/j.js"></script>

 

In the above pixel example, the following <img src="…"> tracking parameters are static and should be the same for all orders. The bold section is the value.

merchantID=XXXXX

Your Merchant ID (XXXXX), which can be found in the top left corner of your ShareASale account.

 

transtype=sale

 

The transtype parameter is simply set to ‘sale’ for all sale tracking pixels. Tracking leads is covered in a different document.

 

In addition to the two static tracking parameters above, the pixel must include two dynamically populated tracking variables:

 

tracking=OrderID 

 

The tracking parameter must always be populated with a unique record locator. The value reported here should be able to be used to locate records in your system if there is a discrepancy in the tracking data recorded by ShareASale or more likely, if you need to cancel or edit a sale commission (e.g. customer returns).

 

amount=AA.BB

The amount parameter must be passed with a non-zero amount formatted to two decimal places. This value should be the order subtotal after discounts, but before any taxes or shipping are added.

 

Note: Dynamically populating <img> tracking pixel parameters is accomplished through macros, variables, and/or data layer attributes your cart system or tag manager provide. They’re always delimited by an ampersand (&parameter1=value1&parameter2=value2).

Speak to your tech/dev team if you are unsure how to populate any of the documented tracking parameters.

 

2.2.      Product Level Tracking

Product Level Tracking can be configured using the skulist, pricelist, and quantitylist parameters as noted below. All three parameters must be passed together, and their values must be URL-encoded.

skulist=SKU1,SKU2

The skulist parameter passes a comma-delimited list of the SKUs of each line-item in the cart.

 

pricelist=PRICE1,PRICE2

The pricelist parameter passes a comma-delimited list of the Prices of each line-item in the cart.

 

quantitylist=Quantity1,Quantity2

The quantitylist parameter passes a comma-delimited list of the quantities of each line-item in the cart.

 

NOTE: Pricelist parameters should reflect each items price after discounts, before taxes and shipping. All pricelist values multiplied by their respective quantitylist values and summed should equal the amount parameter’s value.

 

If you are configuring product level tracking to set up commissions for different products purchased you’ll also need to upload a full product datafeed of your products. Please contact us at ShareASale@ShareASale.com for more information.

2.3.      Coupon Code Tracking

The ShareASale tracking pixel can be configured to track coupon codes for exclusive commission attribution to specific Affiliates and to control commission amounts based on coupon usage. To do so, append the couponcode parameter formatted as noted below.

 

couponcode= COUPON1,COUPON2

Replace COUPON1,COUPON2 with the comma-delimited list of coupon(s) used in an order by the customer. This example had two coupon codes used.

2.4.     Customer Status Tracking

The ShareASale tracking pixel can be configured to track customer status using the newcustomer parameter. This is often used to award a higher commission for new customer referrals.

newcustomer= X

Replace X with either

1 – If the customer is a new customer

0 – If the customer is not a new customer

No Value – If the customer status is unknown (e.g. guest checkouts)

 

The newcustomer parameter should be set based on one or more common values, such as the customer’s email address, previous orders count, etc. and toggled based on whether a previous transaction has occurred with those same values.

2.5.      StoresConnect

The ShareASale tracking pixel can be configured to track data from more than one store/site per account using our no-cost StoresConnect feature. 

storeid= X

Replace X with the ID of the store that this pixel will be installed in.

 

If you have not already set up StoresConnect and would like to, please contact our support team at ShareASale@ShareASale.com

2.6.     Situational Tracking Parameters

In addition to the parameters in the section above, it is also possible to pass additional data related to the order into the ShareASale system. Each of these parameters can be appended to the pixel string with standard query string ampersands (&).

 

Currency=ABC

Replace ABC with the three letter ISO-4217 currency code for the currency used by the customer, i.e. EUR for Euros, GBP for British Pounds, USD for US Dollars.

 

xtype=type

The Merchant Defined Type can be used to pass a value for type which can then be accessed from Tools >> Commission Rules to create particular commission structures. This is useful if there is data ShareASale should receive that does not neatly fit into another parameter’s purpose.

 

persale=T

If necessary, a commission rate override for this sale transaction. This override can still be overridden by other higher commission arrangements such as Product-Level, or Commission Rules. Values of T should be numbers, and will be interpreted as either a percentage or flat amount based on your account's program default commission setting.

 

autovoid=V

The autovoid parameter can be appended and set to 1 in order to allow a record to be recorded in ShareASale but not pay any commission to the Affiliate. This should only be used in multi-network tracking situations. Please contact our support team for further information.

 

pendingdate=mm/dd/yyyy

The ShareASale pendingdate parameter allows you to set the minimum lock date for a transaction. The goal is to ensure that you can void or edit sales tracked within ShareASale up until the revenue from that sale is realized. Contact our support team to enable.

Ex. &
pendingdate=06/25/2018

You will then be able to edit or void that transaction within ShareASale up until the 20th of the month following the date specified (i.e. 7/20/2018 above). The date specified must be in the future, or the parameter will be ignored.

2.7.              First-party cookie tracking (required, Fall 2018)

By Fall 2018, ShareASale will begin passing a click ID value in the Merchant landing page URL (www.example.com/landing?sscid=XYZ) of all Affiliate traffic linked to your site.

An additional tracking "master" tag covered in section 3 checks for this ?sscid=… landing page URL parameter, and stores it as a first-party cookie (under your domain, not just ShareASale’s). This helps with tracking accuracy under certain browsers that disallow access to third-party cookies (accessing shareasale.com cookies from the Merchant’s example.com domain). You might hear this method referred to as "cookieless" tracking on other Affiliate networks.

When the order confirmation "thank-you" receipt page is being displayed, this cookie named shareasaleSSCID must have its value retrieved and used to populate the sscid= tracking pixel parameter. The sscidmode= tracking pixel parameter has a static value, but should be appended too.

sscid=clickID

The click ID value last stored in the shareasaleSSCID first-party cookie.

 

sscidmode=6

 

The sscidmode parameter is simply set to ‘6’ for all sale tracking pixels.

Retrieving the value from the shareasaleSSCID cookie to populate the sscid= tracking pixel parameter can be done a few ways, depending on your cart and whether you’re using a tag manager like Google Tag Manager.

2.7.1.                       Server-side PHP example

$sscid = ! empty( $_COOKIE['shareasaleSSCID'] ) ? $_COOKIE['shareasaleSSCID'] : '';

This sets the value of $sscid  PHP variable to the cookie named shareasaleSSCID if it exists.

2.7.2.                      Client-side JavaScript example

function shareasaleGetCookie(e){var r=e+"=";var a=decodeURIComponent(document.cookie);var o=a.split(";");for(var n=0;n<o.length;n++){var t=o[n];while(t.charAt(0)==" "){t=t.substring(1)}if(t.indexOf(r)==0){return t.substring(r.length,t.length)}}return""}

This minimized function shareasaleGetCookie returns the value of any cookie named in the first argument passed, i.e. shareasaleGetCookie(‘shareasaleSSCID’) returns the shareasaleSSCID value.

2.7.3.                      Google Tag Manager example

Figure 1: First-party cookie variable type, set to shareasaleSSCID name.

This easy GTM variable {{ShareASale Click ID}} that will be set to the value of the needed shareasaleSSCID cookie.

2.8.              Install the tracking pixel code.

Now that the ShareASale conversion tracking pixel’s various parameters are covered, we’ll need to install it in the right place on your site.

2.8.1.                        Find the file, template, or section of your cart admin that allows you to customize the site’s checkout "thank-you" receipt page.

·         It should be the page immediately after finishing a sale purchase on your site.

·         Make sure to find the page or place that only displays content once after finishing an order, and not again later like the order status, order history, email confirmation, etc.

·         If you’re editing a file that is part of your site’s checkout, be sure to back it up beforehand.

Figure 2: An example of a thank-you order confirmation receipt page as viewed by the customer.

 This is where the invisible ShareASale tracking pixel code will be installed from your backend.

2.8.2.                     Place the tracking pixel code within the HTML <body></body> of the checkout "thank-you" receipt page.

·         Be careful not to accidentally place the code inside another existing section of code that might become broken.

·         Don’t place it within any <noscript> tags. These only execute if JavaScript is disabled in the browser (rare for users).

·         Some carts require you clear a cache or re-publish any changes you make to files. Double-check with your cart’s expert.

·         Make sure the secondary <script defer async type="text/javascript" src="https://shareasale-analytics.com/j.js"></script> tag is underneath the pixel <img> tag being populated with order data.

Figure 3: The success.phtml page file from a Magento™ cart backend. The code here sets PHP $variables that populate the various tracking parameters before the pixel is printed onto the page at the end.

Congratulations, the ShareASale tracking pixel has been installed! Proceed to the next section for installing the "master" tag that belongs on every page of your site, and sets the aforementioned shareasaleSSCID first-party tracking enhancement cookie.

3.    Master tag Installation Instructions (required, Fall 2018)

3.1.                Understand the "master" tag’s setup and purpose.

ShareASale requires a second tag that should be embedded on every page of your site. Usually this is accomplished by including the tag in a common global file, like the header or footer template. Alternatively, cart systems will often have a dedicated spot in their admin for including code like this, as it’s fairly commonly required for analytics platforms like Google Analytics.

This second tag’s code watches for any ?sscid= query string parameter in the landing page URLs of your site, indicating ShareASale Affiliate traffic. If it’s present, it stores the parameter’s value as a cookie under your domain too. Later this cookie’s value is retrieved and passed to our tracking pixel. It enhances tracking in certain browsers like Safari or more restrictive user settings scenarios.

<script>

var shareasaleSSCID=shareasaleGetParameterByName("sscid");function shareasaleSetCookie(e,a,r,s,t){if(e&&a){var o,n=s?"; path="+s:"",i=t?"; domain="+t:"",l="";r&&((o=new Date).setTime(o.getTime()+r),l="; expires="+o.toUTCString()),document.cookie=e+"="+a+l+n+i}}function shareasaleGetParameterByName(e,a){a||(a=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var r=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(a);return r?r[2]?decodeURIComponent(r[2].replace(/\+/g," ")):"":null}shareasaleSSCID&&shareasaleSetCookie("shareasaleSSCID",shareasaleSSCID,94670778e4,"/");

</script>

The ShareASale master tag code. It’s a simple <script> tag that sets a first-party cookie called shareasaleSSCID on your domain when ?sscid= is in the landing page URL.

3.2.              Add the master tag tracking code above.

3.2.1.                       Find the file, template, or section of your cart admin that allows you to place code that will be included on every page of the site.

·         The best place is the HTML <head></head> section, if possible.

·         Just install it once, not multiple times (i.e. not the header and footer by mistake).

·         If you’re editing a common global file for your site, make sure you’re editing the right one for your theme. Often carts can have multiple themes/skins, and if you change you will need to re-integrate the master tag on that new theme too.

3.2.2.                      Place the master tag code so that it appears on every page of your site. See examples below.

Figure 4: An example of including the ShareASale master tag code in Google Tag Manager (GTM).

Figure 5: Installing the ShareASale master tag code into a Magento™ 2 cart HTML Head customization section from the admin.

Congratulations! Installation is now complete. The following sections detail how to test that everything is working properly.

4.    Testing

Now that your tracking tags have been installed, we will need to test that everything is working as expected. To do this, we’ll simulate an Affiliate referred purchase by clicking a ShareASale test link and then running a purchase on your store.

If the test is successful we’ll see a record appear in your ShareASale console, which we will VOID so that it doesn’t debit commissions from your account.

4.1.               Click the test link.

In the email you received with this document there is a test link like the example below.

EXAMPLE TEST LINK:

http://www.shareasale.com/r.cfm?b=YYYYY&u=178&m=XXXXX&urllink=&afftrack=

NOTE: If you do not click the test link your order will not track. This is just a reference link, and not what you should use for testing. You can also get a test link after login, here.

4.2.              Run a test purchase.

The test link should direct you to your own store. Once there, please purchase any item in your store. Sometimes Merchants will have a test item worth $1.00 sale price, but above $0.00 minimum.

4.3.              Check that the test purchase tracked.

After the purchase is complete, navigate to www.shareasale.com in your browser and log into your account.

4.3.1.                       Click Reports and then click Transaction Details from the drop-down menu.

 

Figure 6: Navigate to Reports >> Transaction Details

4.3.2.                     Filter the report for Affiliate ID 178 using the panel on the left.

 

Figure 7: Filter for Affiliate 178

4.3.3.                     The filtered view should now show your test purchase as an entry with today’s date.

Figure 8: Verify that the order tracked

4.3.4.                     If the order tracked successfully

 

Your account is now ready to use ShareASale with your store. Please contact us at ShareASale@ShareASale.com for further information about:

·         Product specific commissions (offer different commissions by product)
·         New customer incentives (offer commission bonuses for new customers)
·         Exclusive coupon codes (used for tracking conversions without link clickthrough)

 

4.3.5.                     If the order does not show up in the Transaction Details Report

 

Please verify that you have completed all of the steps as instructed. Common mistakes include not entering the correct Merchant ID in step 2.1 and forgetting to click the test link in step 4.1.

If after verifying all of these steps your tracking still does not work please contact our support team at ShareASale@ShareASale.com.