Adding new tracking scripts and pixels to WordPress can be annoying:
- Copy script
- Open your theme file
- Paste code
- Hope something doesn’t break
Plus, it can be time consuming to debug different scripts and hard to keep track of all the 3rd party scripts you’ve installed.
Thankfully there’s a solution: Google Tag Manager.
And in this guide I’m going to walk you through how to add Google Tag Manager to your WordPress site in under 5 minutes.
Step-by-step guide to install Google Tag Manager on WordPress
1. Log into WordPress
2. Go to Plugins/Add New
3. Search for “tag manager”
4. Install the “Google Tag Manager for WordPress” by Thomas Geiger
5. Activate plugin
6. Navigate to Settings/Google Tag Manager from inside your WordPress admin panel
7. Open a new tab and head over to https://tagmanager.google.com/
8. Copy your Tag Manager container id. Your id begins with “GTM-”
9. Paste your GTM id in to the “Google Tag Manager ID” field inside the “General” tab of the Tag Manager plugin you installed.
10. Select “Custom” from the “container code placement” options list
11. Click “Save Changes”
12. Copy the code you see at the bottom of the “Container code placement” section
13. Click on Appearance/Theme Editor
14. Paste code into header.php
15. Find the header.php file from the list of “Theme Files” on the right-hand side of the page.
16. Scroll down untill you see the opening body tag <body>
17. Paste the code you copied in the preview step below the body tag and click “Update File”
18. Install Tag Asssistant browser extension-
This chrome extension will help you to make sure Tag Manager is installed correctly.
- Head over to Google and search for “Tag Assistant chrome extension”
- Click “Add to Chrome”
Optional: Pin the “Tag Assistant” extension to your browser
Once installed you’ll be able to see the Tag Assistant extension in your browser.
Copy your Google Analytics “Tracking ID”
19. Open your Google Analytics account
22. Click on the Property you want to work with
23. Click “Property Settings”
24. Copy your “Tracking ID”
Add new tag in Google Tag Manager
25. Click “Add a new tag” in Google Tag Manager to track your Google Analytics Pageviews
26. Click on “Google Analytics: Universal Analytics”
27. Click on “New Variable”
28. Paste your Google Analytics ID
This ID was copied from your Google Analytics property and begins with “UA-”
29. Click on “Triggering” to create a new trigger
30. Select “All Pages”
31. Click Save
32. Click “Submit”
33. Add a version name
It’s good practice to make notes to every change you make to your GA container so that you keep track of what changes were made, why and in case something stops working you can use this to retrace your steps.
34. Then click “Publish”
Google Tag Manager is now installed
You should be all done now with the basic installation of Google Tag Manager on your WordPress site. To make sure, open your website in a new tab, click on the “Tag Assistant” chrome extension, Click “Enable”. Then, refresh the page and you will see your Google Tag Manager container in the Tag Assistant along with information about the status each Google tag added to your container.
If you see all green icons in there you are good to go. If not, feel free to leave me a message here and I’ll help you find a solution.