Here’s a straightforward, comprehensive guide on how to add Google Tag to your WordPress site. This tutorial is perfect for beginners, as each step is detailed and explained to provide absolute clarity.
What is a Google Tag and why add one to WordPress?
A Google Tag is a small piece of code that is added to a website. It allows you to track the activity of your visitors and understand how they interact with your site. This data can be invaluable when you’re trying to optimize your website for both search engines and usability. Adding Google Tags to a WordPress site can sound complex, but with this guide, you’ll be able to do it in no time.
Step 1: Setting up a Google Tag Manager Account
To start adding a Google Tag to your WordPress site, you first need to set up an account in Google Tag Manager (GTM). You can do so here
- 1.1 Click on the ‘Create Account’ button on the landing page.
- 1.2 Fill out all the necessary fields, such as your account name, country, and container name (typically the URL of your website). Choose ‘Web’ as a target platform.
You should then be redirected to your GTM dashboard, with your created container.
Step 2: Getting Your Google Tag Manager Codes
After creating your container, Google will provide you with two code snippets:
- 2.1 In your GTM dashboard, click on ‘Admin’ in the upper menu. Under the ‘Container’ column, click on ‘Install Google Tag Manager’.
You’ll see two distinct code snippets.
– The first code should be installed as high up in the HTML
<head> tag of your site as possible.
– The second code should be installed immediately after the opening
<body> tag on every page of your site.
Step 3: Adding the GTM Codes to Your WordPress Site
The next step is adding these snippets to your WordPress site. You can do this manually, or with a plugin.
To do it manually, go into your theme’s files. Locate the
header.phpfile and then paste the first code in the
<head>tag and the second one after the
<body>tag. Just be careful editing these files – a single misplaced line of code can break your site!
If you’re not confident doing this manually, use a plugin like Insert Headers and Footers. After installing and activating the plugin, navigate to Settings -> Insert Headers and Footers in your WordPress Dashboard. Paste the first code in the Scripts in Header box, and the second code in the Scripts in Body box. Hit Save.
In both cases, it’s pertinent to make a full website backup before making any changes to prevent losing any data.
Step 4: Checking if GTM is Working
To confirm that you’ve successfully added your GTM code to WordPress, use the Google Tag Assistant Chrome Extension.
- 4.1 Install the extension and navigate to your website.
- 4.2 Click on the extension’s icon and hit ‘Enable’.
- 4.3 Refresh your webpage.
If everything is implemented correctly, you should see a green tag with a smiley icon on the extension.
Step 5: Adding and Publishing Your First Tag
With the GTM installed, you can now add tags to your website.
- 5.1 In your GTM dashboard, navigate to your container and click on ‘New Tag’.
- 5.2 You can then select what sort of tag you’d like to add from a variety of options. For beginners, the Google Analytics: Universal Analytics tag is a good start.
- 5.3 After setting up the tag, hit ‘Save’. Then click on the ‘Submit’ button at the top right of your GTM dashboard to publish your newly created tag.
And that’s it! You’ve successfully added a Google Tag to your WordPress site. It’s recommended to monitor your tag activity closely to glean useful insights about your website traffic.
Success with WordPress and GTM starts with understanding. Keep learning, experimenting, and optimizing. The growth of your website is just a few tags away.