Introduction & Purpose
The purpose of this article is to demonstrate the correct way to place GTM snippets for tracking user interactions with a web page.
Developer required to update HTML.
- GTM Container Created and Published
- Ability to edit the HTML of the page you wish to track<
- Open your GTM container and click the Admin tab
- Under the 'CONTAINER' column, click 'Install Google Tag Manager'
- Copy and paste the provided snippets where instructed (<head> or <body>), for every page you wish to track.
After updating HTML with code snippets from GTM, open the browser to the page and right-click > inspect the page to reveal HTML.
Search the HTML for your container ID (GTM-XXXXXXX). One of the results should be the <head> code snippet provided by Google Tag Manager in the previous steps.
Ensure that the snippet provide by GTM is unmodified and entirely under the <head> tag, not the <body>.
Incorrect placement example -
Search the HTML for your container ID (GTM-XXXXXXX). One of the results should be the <body> code snippet provided by Google Tag Manager in the previous steps.
Ensure that the snippet provide by GTM is unmodified and entirely under the <body> tag, not the <head>.
- Open the network tab from any page you wish to validate: right-click > Network tab
- Input into the search: "gtm.js"
- Ensure that the network request is logged and the Status is 200 (Success).
This validates that the page has been tagged correctly and is sending data to Google Analytics.