#
Google Tag Manager
Manage all your website's tags in one place.
Tag management made easy. Google Tag Manager delivers simple, reliable, easily integrated tag management solutions - for free.
#
Prerequisites
- Preexisting website.
#
Install GTM on your Website
Go to Google Tag Manager and login to your account. If you don't have one, create a new account.
Set up a container for your website (e.g., "www.example.com").
After creating the container, Google Tag Manager will provide you with two code snippets: one for the
section and another for the section of your website.Add the GTM Code to Your Website.
Copy snippet in head tag
- Copy the first code snippet.

Navigate to the CMS and select the website where you want to add GTM to.
Click on Update Website.

- Navigate to the Meta Information tab.

- Paste the code snippet on the Global Header Insert textarea.

- Click Submit.
Copy snippet in body tag
- Copy the second code snippet.

- Go to the file that serves as your base template.

- Paste the code snippet at the top of the file.

- Click Publish.

Copy snippet in head tag
- Copy the first code snippet.

Log in to your WordPress Dashboard.
Navigate to Tools and then to Theme File Editor.

- Paste the code snippet in the
header.phpfile.

- Click Update File.
Copy snippet in body tag
- Copy the second code snippet.

- Paste the code snippet in the
footer.phpfile.

Note:
If your website does not have a footer.php, paste the code in the header.php immediately after the opening body tag.
- Click Update File.
Copy snippet in head tag
- Copy the first code snippet.

Log in to your Drupal Admin Dashboard.
Navigate to Admin and then to Appearance to find your active theme.
- Find the
html.html.twigfile in your active theme directory (e.g., /themes/custom/[your-theme-name]/templates/).
Note:
If it doesn’t exist, you may need to create one or copy it from the core or base theme.
- Paste the code snippet in the
html.html.twigfile immediately before the closing</head>tag.
Copy snippet in body tag
- Copy the second code snippet.

Paste the code snippet in the
html.html.twigfile immediately after the opening<body>tag.Clear your Drupal cache by navigating to Configuration > Performance and clicking Clear All Caches.
- Use the "Preview" mode in Google Tag Manager to check if the tags are firing correctly, or use the Google Tag Assistant extension in your browser to verify the installation.