Google Tag Manager Integration

You can integrate with Tracknow in order to be able to track sales on your website using Google Tag Manager. In this integration, GTM is used in order to load the necessary scripts.


Prerequisites

This integration method require you to enable passing our unique affiliate identifier click_id to your landing page.

For instructions, click herearrow-up-right.


Storing the click_id Using GTM

Once the click_id is passed to the webstore, it should be saved in a browser cookie to ensure it persists as the customer navigates between pages. The click_id must still be available after a successful purchase so it can be included in the postback to Tracknow together with the purchase details.

In Google Tag Manager, create a new Page View trigger and set it to fire on All Page Views. This ensures the click_id is captured and saved no matter which page the customer lands on, so it won’t be missed if they enter the site on a deep link.

Finally, you’ll need to add the script responsible for storing the click_id.

In GTM, go to Tags New → Create a Custom HTML type tag.

Copy the code above, replace the ENTER YOUR NAMESPACE HERE placeholder with your actual Tracknow namespace and paste the adjusted code in the GTM custom HTML code box.

Select the trigger you previously created as this tag’s trigger.


Sending Purchase Data Using GTM

To send purchase data to Tracknow, use the webstore’s Thank You / Order Confirmation page as the trigger for firing the postback. This ensures the postback is sent only after the purchase has been successfully completed.

In GTM, create a new Page View trigger and set it to fire on Some Page Views. Then configure the condition so it fires only when the webstore’s Thank You page is viewed: set Variable to Page URL, choose Contains as the match type, and enter the Thank You page URL path (e.g., /thank-you).

Next, you’ll need to add the script responsible for storing sending the postback.

In GTM, go to Tags New → Create a Custom HTML type tag.

Copy the code above and update the placeholders as follows:

  • Replace ENTER CAMPAIGN ID HERE with the Tracknow campaign ID you want to attribute the conversion to.

  • Replace ENTER NAMESPACE HERE with your Tracknow namespace.

You can include additional parameters in the postback to capture more purchase details from the webstore by adding them under the script’s params object. To see the full list of parameters Tracknow supports, click herearrow-up-right.

For any parameter that should be populated dynamically (for example, the order total or order ID), replace the placeholder value in the code with the correct macro (Data Layer Variable Name) for that value (as provided by your webstore/GTM setup).

Select the postback trigger you previously created as this tag’s trigger.


Important Notes

On single-page applications (SPAs), navigation typically happens without a full page reload. As a result, a standard Page View trigger may not fire when the user moves between routes. In these cases, use a History Change trigger to detect URL changes and fire your tag accordingly.

Last updated