--- title: "GTM - Practical Tips" slug: "gtm-practical-tips" description: "Simple practical tips with custom solutions and custom code examples for Awin client-side tracking integration via GTM." updated: 2026-08-19T10:48:34Z published: 2026-08-19T10:48:34Z canonical: "help.awin.com/gtm-practical-tips" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.awin.com/llms.txt > Use this file to discover all available pages before exploring further. # GTM - Practical Tips When implementing Awin via Google Tag Manager (GTM), the integration of both [client-side](/developers/docs/gtm-client-side) and [server-side](/developers/docs/gtm-s2s) Awin Tracking is mandatory. You may well find a solution for your specific use case in the implementation examples and custom solutions below. Naturally, there may be various possible approaches. ## Custom Solutions Custom Code Examples Discover a solution for your use case in the following compilation. In some cases, it can be helpful to use customer-specific solutions via custom code. ### Setup Data Layer Variables **Example for custom specific Data Layer Setup** Place the following code on the confirmation page of your website (the code must be positioned above the Google Container code on the page): ```javascript ``` The text in { brackets } are placeholders – it will need to be replaced with the variables your site uses for the following information: - transactionTotal: The total cost of the sale (before or after VAT/delivery) - transactionCurrency: The ISO currency code for the currency that was used on the transaction - transactionID: The unique order reference associated the transaction - transactionPromoCode: The voucher code used with the transaction (optional) You may wish to use PHP to load these variables. Alternatively, if you are using a third-party eCommerce platform, their support team may be able to provide you with the variables to use. Example If a customer purchases a product for £5.99 using the voucher code 'HALFPRICE', the code should load on the confirmation page as: ```javascript ``` Publishing Tags Within Google Tag Manager When you have implemented all of the required functionality into the Tag Manager interface, click Publish to apply the changes to your site. ### Array For Custom Parameters Custom JavaScript to create an array for custom parameters: ```javascript function() {  return [    "{{value1}}",    "{{value2}}",    "{{value3}}",  ]; } ``` ### Shop Content First Example In cases where data is missing (resulting in "undefined" values) or loading delays occur, it can help to load the Awin ConversionTag or MasterTag only after all page content has finished loading. This ensures that all order data is available before being transmitted to Awin. GTM offer “content first” trigger events: - "DOM Ready" or - "Window Loaded". ![DOM ready](https://cdn.document360.io/ec9ead62-8ecc-46ef-aac7-9b0a9081b40b/Images/Documentation/GTM-dom-ready.png) Related links for this loading event topic: [https://support.google.com/tagmanager/answer/7679319?hl=en](https://support.google.com/tagmanager/answer/7679319?hl=en) [https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event) ### Mastertag Integration In Single-Page Application This solution will work if page url is changing when user moves to different sections of the Single-page Application (sometimes short: SPA). use case: mastertag integration in single-page application using Google Tag Manager - Create a Journey Tag to fire on a Landing page but not checkout page - Create a History Change Trigger with exception (don't fire on checkout page) ![GTM in SPA - mastertag via history change event trigger](https://cdn.document360.io/ec9ead62-8ecc-46ef-aac7-9b0a9081b40b/Images/Documentation/gtm-spa-mastertag-history-change-event-trigger.png) - Create a Custom HTML Tag, name it Awin Mastertag - History Change and use the code below (replace the XXXX with Advertiser ID) ```javascript ``` - Add the History Change Trigger to Awin Mastertag - History Change and save the tag ![mastertag incl. cachebuster with history change trigger](https://cdn.document360.io/ec9ead62-8ecc-46ef-aac7-9b0a9081b40b/Images/Documentation/mt-cachebuster-with-history-change-trigger.png) ### Removing VAT Or Shipping Costs From Amount Use case: reduce order total value by the amount of Value Added Tax (VAT) and shipping costs (target: net amount). - Create a new Custom JavaScript ![GTM : custom javascript](https://cdn.document360.io/ec9ead62-8ecc-46ef-aac7-9b0a9081b40b/Images/Documentation/custom-js.png) - Let’s make a code that takes the DataLayer variables for the total revenue, the VAT and the shipping fee, and run a subtraction equation using the “-“ (minus) [JavaScript Subtraction Operator](https://www.w3schools.com/js/js_operators.asp#:~:text=--,subtraction). Use the following code as a base, and edit to your needs: ```javascript function(){  // UPDATE the {{}} variables to your DataLayer variables.    var revenue = {{Transaction Revenue}};  var vat = {{Transaction VAT}};  var shipping = {{Transaction Shipping}};    var totalAmount = revenue - (shipping + vat);    return totalAmount.toFixed(2); } ``` The above code will return the resulting value from the subtraction equation, rounded with 2 decimal cases using the [.toFixed( )](https://www.w3schools.com/jsref/jsref_tofixed.asp) method. - Then simply use this custom JavaScript variable in the Awin Conversion Tag. Monitoring user journey from affiliate to advertiser. Page where users land after clicking a link. The ID of the Affiliate Program on Awin. ## Related - [Client-Side Tracking](/gtm-client-side.md) - [Server-side tracking](/gtm-s2s.md) - [Consent Signals](/gtm-consent.md)