Overview
Aspire's Javascript Postback tracking is a privacy-compliant tracking method that offers client-side functionality for session storage and conversions with minimal setup effort. Sessions and conversions can be generated inside the end user's browser by implementing the tracking scripts on your website.
This article will walk you through adding the Javascript Postback tracking scripts to a page to start and store sessions, then post a conversion.
Important Considerations:
Javascript Tracking only supports same-site and cross-origin conversions at this time.
If your e-commerce store supports multiple currencies, please see this help article for further instructions.
Directions
Step 1: Recording Clicks
To record a click and start a session when a user arrives at a product or landing page, simply paste the code below to the head of your site to add the Postback’s functionality.
<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>
The identify method is called when you want to store or generate a user's session. If you're familiar with our sales links, this method largely corresponds to a "click.” As you see in the above snippet code, the identify method is called like so:
tdl.identify()
That will pull the transaction_id parameter from the URL's query string and store it in the user's browser's local storage.
We recommend using a backend template or theme to help put the call into the footer or header of every page of your site a user might first visit. That way, no matter which page or product the user first lands on, they will always store their session.
Note: Aspire can only track sessions on pages where the tdl.identify() call has been added.
Step 2: Recording Conversions on Checkout
The convert method lets you record a conversion using the user's stored session. Since the session's transaction ID has the associated affiliate and offer IDs, you do not need to include these when calling the convert method.
At its most basic, the convert method is:
tdl.convert()
The following script should be placed on the thank you page after purchase or whichever page indicates a conversion has taken place.
<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.convert()
</script>
In order to track the Sale Amount and Order ID, it is important to include the conversion link parameters in your scripts.
tdl.convert([conversion_data]);
For Aspire to determine the correct payout for offers that provide commission, you must pass the sale amount in the postback URL. We also recommend passing through the Order ID.
To pass the sale amount and order ID, append the following parameters to your conversion link:
amount
adv_unique1
The order ID is usually passed into an adv_unique field. Your engineering or eCommerce team should help you provide the desired information as a value in that parameter.
Below is an example of what this would look like for a Shopify brand. Keep in mind that each eCommerce conversion data is different, so we recommend consulting with your engineering or eCommerce team.
tdl.convert(
{
'amount': cartSubtotalUSD,
'adv_unique1': event.data.checkout.order.id,
}
)
Optionally, you can also add any additional parameters you'd like to include on the conversion by passing them to the convert method.
Note: Ensure the thank you page that adds the convert function script doesn’t repeat the click (Step 1). Having both on the same page can cause double-counting clicks in your reports.
Step 3: Configure Your Offer & Place a Test Order
The final step is to configure your Link Tracking Offer within your Aspire account, then place a test order.
Go to Reporting > Sales Tracking to create a new Link Tracking Offer or configure an existing one. Within your Offer settings, there are two main requirements:
Under Conversion & Tracking, the "Conversion Tracking" method must be set to Javascript Postback.
Within the Offer URL Tracking, you must append
transaction_id={transaction_id}
to the end of the URL.
For example, if you're directing traffic to:https://brand.com/shop
You'll want to ensure the transaction_id is being appended like so:https://brand.com/shop?transaction_id={transaction_id}
Once you've created an offer, we highly recommend placing a test order before generating links for your members to confirm that clicks and conversions are being tracked properly.
Frequently Asked Questions
Is this a one-time setup or something we'll need to complete for each Link Tracking Offer we create?
This is a one-time setup process.
Does Aspire use first click or last click attribution?
We use last click attribution. If two members refer a sale, the last member to refer the user to the conversion page will receive the credit.
What is the conversion window for Javascript tracking?
The default conversion window is 30 days. This is how long a session starting on click can last and still be converted on.
Please note that Apple’s Safari browser deletes all first-party cookies and other script-writable storage after 7 days without user interaction. This means the conversion window on Apple devices will be capped at one week.