Setting up Affiliate Tracking for Google Tag Manager (GTM)
- 13 Sep 2024
- Print
- DarkLight
- PDF
Setting up Affiliate Tracking for Google Tag Manager (GTM)
- Updated on 13 Sep 2024
- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Grin's affiliate integration uses JS tracking scripts loaded on your storefront pages. If you are using a native integration (Shopify, WooCommerce, Magento, SFCC) these scripts are installed either fully or in part via the respective Grin app/plugin/extension/module for your native store, but you may wish to install these scripts using Google Tag Manager instead for more centralized management of your storefront's installed scripts. Additionally for non-natively integrated storefronts GTM may be your primary way of installing scripts or the best option for you as well.
There are 2 scripts that need to be installed:
- The SDK tracking script. This script:
- (Required) Must be configured in GTM to execute on any storefront page that you will be pointing your affiliate links to target as landing pages.
- (Required) Must be configured in GTM on your order Thank You page.
- (Optional, but highly recommended) should be installed on any other storefront pages that you wish to track visits to.
- (Required) Leverages query string parameters passed through from the affiliate link. Those parameters must be preserved through the 1st time the script loads for a given session. If your site strips them before the script initially fires, tracking will not succeed.
- Does not require any kind of modification.
`<script>
(function() { Grin = window.Grin || (window.Grin = []); var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://d38xvr37kwwhcm.cloudfront.net/js/grin-sdk.js'; var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x); })();
</script>`
- The conversion script. This script:
- (Required) Must be updated to include your GTM-compatible variables for amount, order number, and currency.
- (Required) Must be configured in GTM to execute on the order Thank You page.
`<script>
// set the GTM variable for subtotal (before taxes and shipping, after discounts) amount here
var amount = 'INSERT GTM VARIABLE FOR SUBTOTAL';
// set the GTM variable for order number
var order_number = 'INSERT GTM VARIABLE FOR ORDER NUMBER';
// set the GTM variable for currency code in ISO 4217 format
var currency = 'INSERT GTM VARIABLE FOR CURRENCY CODE';
// send the conversion to Grin
Grin = window.Grin || (window.Grin = []);Grin.push(['conversion', amount, {order_number: order_number, currency: currency}]);
</script>`
Was this article helpful?