All Collections
Sales Tracking
Javascript Postback Tracking
Aspire Javascript Postback Tracking for Shopify Plus
Aspire Javascript Postback Tracking for Shopify Plus

How to implement Aspire's Javascript Postback Tracking for Shopify Plus users

Janine Borrega avatar
Written by Janine Borrega
Updated over a week ago

Aspire's Javascript Postback tracking provides a cookieless tracking solution for brands running their networks. Sessions and conversions can be generated inside the end user's browser by implementing the tracking scripts on any page of your website.

The Aspire Javascript postback offers client-side functionality for session storage and creator conversions. By utilizing the Javascript postback, you'll have the accuracy of server-side postback with minimal technical setup effort. This article will walk you through adding the Javascript postback Tracking scripts to a page to start & store sessions and then post a conversion.

Before you Begin

You'll need to go through a few steps in Aspire before using the Javascript Postback to interact with an Aspire Sales Tracking Offer.

  1. The Javascript Postback utilizes "server-side" postbacks. For the Javascript Postback to work, you'll need to set the Conversion Tracking method of your link tracking offer in Aspire to "Javascript Postback".

  2. In the Offer URL, you'll need to ensure you're forwarding the transaction_id as a parameter on the URL.

    For example, if you're directing traffic to:

    https://advertisersite.com/storefront

    You'll want to ensure the transaction_id is being appended like so:

    https://advertisersite.com/storefront?transaction_id={transaction_id}

Using the Aspire Javascript Postback to track the activity on a Shopify Plus store requires placing the Scripts code in two different locations:

  1. On a landing or product page where a click should be recorded and a tracking session should begin

  2. On the checkout page to mark when a conversion has been completed

Step 1: Recording Clicks on Product Pages

To record a click and start a session when a user arrives at a product or landing page, you must add a simple code snippet to the master template.

  1. Navigate to the theme.liquid master template by selecting Themes under Online Store and clicking on Actions > Edit Code.

  2. Select theme.liquid in the menu on the left under Layout and you will see something like this.

  3. Paste the following tracking snippet at the top of the file right below the first <head> tag:

<script> 

!function(){var o=window.tdl=window.tdl||[];if(o.invoked)window.console&&console.error&&console.error("Tune snippet has been included more than once.");else{o.invoked=!0,o.methods=["init","identify","convert"],o.factory=function(n){return function(){var e=Array.prototype.slice.call(arguments);return e.unshift(n),o.push(e),o}};for(var e=0;e<o.methods.length;e++){var n=o.methods[e];o[n]=o.factory(n)}o.init=function(e){var n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://js.go2sdk.com/v2/tune.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(n,t),o.domain=e}}}();

tdl.init("https://aspireiq.go2cloud.org")
tdl.identify()
</script>

Step 2: Recording Conversions on Checkout

To record a conversion when a user successfully checks out, a second snippet must be pasted in the checkout page.

Click on Settings > Custom Events > Custom Pixel > Add New Pixel. Add a Pixel name > select Add Pixel. In the Code box, paste the script below.

Then click Save in the upper right corner, then click Connect.

!function(){
var o = window.tdl = window.tdl || [];
if (o.invoked) window.console && console.error && console.error("Tune snippet has been included more than once.");
else {
o.invoked = !0;
o.methods = ["init", "identify", "convert"];
o.factory = function(n){
return function(){
var e = Array.prototype.slice.call(arguments);
e.unshift(n), o.push(e), o
}
};
for(var e = 0; e < o.methods.length; e++){
var n = o.methods[e];
o[n] = o.factory(n)
}
o.init = function(e){
var n = document.createElement("script");
n.type = "text/javascript", n.async = !0;
n.src = "https://js.go2sdk.com/v2/tune.js";
var t = document.getElementsByTagName("script")[0];
t.parentNode.insertBefore(n, t), o.domain = e
}
}
}();

tdl.init("https://aspireiq.go2cloud.org")
analytics.subscribe('checkout_completed', (event) => {
tdl.convert({
'amount': event.data.checkout.subtotalPrice.amount,
'adv_unique1': event.data.checkout.order.id,
});
});

It should look something like the following.

📌 Important: If your store has installed an app that adds a post-purchase page to your store's checkout, then any custom scripts that you use on your store might not capture certain tracking events. Custom tracking scripts that are added to your store's custom pixel track events on only the order status page, which comes after the post-purchase page in the checkout. If a customer leaves your store on the post-purchase page, then no events on the order status page are tracked.

To ensure that you capture conversion event properly, you may add the existing script that tracks events on the post-purchase page, To do this, grab script you copied above in step 2 and paste it into the box within your Shopify Store Settings > Checkout and Account then go to the Post Purchase page section.

📌 Important: The Javascript postback only supports same-site and cross-origin conversions at this time. Meaning if the domain on the landing page is different than the domain on the checkout page (and it is not a sub-domain), the SDK will not be able to track the conversions. See below for examples.

Supported

1. Single custom Shopify domain

  • Landing page: mystorename.com/landing

  • Checkout page: mystorename.com/checkout

2. Custom domain with sub-domains

  • Landing page: mystorename.com

  • Checkout page: checkout.mystorename.com

Not Supported

1. Default free Shopify domain

  • Landing page: mystorename.myshopify.com

  • Checkout page: checkout.shopify.com

2. Multiple custom Shopify domains

  • Landing page: mystorename.com

  • Checkout page: mycheckoutpage.com

Frequently Asked Questions

Is this a one-time setup or something we'll need to do for every new Sales Tracking Offer we create?

This only has to be done one time! 👍

Can we use Javascript SDK if we have multiple Shopify stores?

Yes! While redirecting from one store to other, the redirect link should contain transaction_id=TRANSACTION_ID so that SDK on the next store can gather the Transaction ID. You can fetch the TRANSACTION_ID value from Session Storage.

Did this answer your question?