Perfectly add Google Analytics to a site to measure website data and gather visitor insights, using Google Tag Manager and verify that it is working properly
Google Tag Manager is properly installed without any technical issues
Why it matters
Google Tag Manager is a great tool to add and manage multiple pixels and tracking codes without needing to edit the code of a site
Before you start
This exact process only applies to WordPress sites
Key steps
34 steps
What is inside
37 headings
1Environment setup8
Download the Google Tag Assistant Companion (Free).
To sign up for Google Tag Manager (Free), you’ll need to log in to your Google account.
If this is your first time creating a Google Tag Manager Account, you’ll be redirected to the account creation page.
Fill in the following information:
Once finished. Click “Create”.
You’ll see a Google Tag Manager Terms of Service pop-up. Select the checkbox and click “Yes”.
You will see the code for installing Google Tag Manager. Ignore this since you won’t be manually adding code to your WordPress site. Click “OK”.
Click on "Submit" > "Publish" > Continue to publish your Google Tag Manager container and that’s it!
2Install and configure the Google Tag Manager WordPress plugin14
Log into your WordPress site.
In the WordPress sidebar, go to "Plugins" > "Add New".
Enter “Google Tag Manager for WordPress” in the search box.
Install the GTM4WP plugin (the image may vary).
To activate the plugin, go to the WordPress sidebar and click "Settings" > "Google Tag Manager".
Paste your Google Tag Manager ID (the one you got from the Google Tag Manager dashboard) in the available field.
The plugin offers several ways to install the container code on your site. Before you implement any of these, we recommend you create a backup of your site.
Copy the PHP code provided by the plugin and click on “Save Changes”.
In the WordPress sidebar, go to "Appearance" > "Theme Editor".
Make sure that you are editing the theme that you currently have installed on your site (you can go to "Appearance" > "Themes" to check the name of the theme you are using).
Select the “Theme Header” template from the list on the right.
This template is different depending on the theme that you have installed. However, you will always be able to find an opening <body> tag in the code.
Paste the PHP code provided by the plugin right below the opening <body> tag.
Click on “Update File”.
3QA your installation12
Open your website homepage using Chrome.
Right-click on the page and select "View Page Source".
Press Ctrl + F (or Command + F on Mac) and search for your GTM ID (e.g., GTM-XXXXXX).
If you do not see the GTM ID in the source code:
Go to Google Tag Manager and open your container.
Click the "Preview" button in the top right.
Enter your website URL in the pop-up window and click "Connect".
A new window will open showing your site with a debug console at the bottom.
Install and open the Google Tag Assistant Companion icon on your browser.
Click on “Add domain”.
Enter your website URL, click “Connect” and reload the page.
If successful, a message saying Tag Assistant Connected will appear.
The document
14 pages
The file is locked
It comes with 2 DAY GEN AI ENGINEERING MASTERMIND, or
with the full library.