Setup Google Analytics using Google Tag Manager

In this tutorial, we will learn how to add Google Analytics to a WordPress website through Google Tag Manager. Previously, we used to add Google Analytics code directly to a WordPress website’s header section. Now, we will handle all the functionality of Google Analytics using the Google Tag Manager code. This will enable us to manage all tracking with a single code. Additionally, Google Tag Manager allows admin users to customize the tracking settings and publish from its dashboard very easily. In the following steps, we will learn more about the settings.

Requirments

  • Google Analytics account.
  • Google Tag Manager account.
  • A WordPress website.

Get the GTM code

  • Log in to the Google Tag Manager site.
  • Create a new account for a new website or subdomain.
  • Fill up all the information properly and click on the Create button. Next, it will ask you to agree to the terms and conditions. Check the box and click the Yes button on the top of the screen.
  • Now, Google Tag Manager will provide us with the code.
  • In WordPress, we only use the GTM-XXXXXX code. Next, we’ll install the WordPress plugin and add the code there. Keep reading the following steps.

Install GTM4WP WordPress plugin

  • Now, we need to install the GTM4WP plugin on our site.
  • Go to your site admin panel >> plugins area. Click Add New link and search for GTM4WP. Install and activate the plugin.
  • Now, navigate to Settings>>Google Tag Manager. In the general tab, enter the code.
  • Next, we will move toward a Google Analytics account and create a new account for our site.

Google Analytics setup

  • Login to your Google Analytics account.
  • From the left navigation, click on the Admin link.
  • Click on the +Create button and click the Account link.
  • Add the account name and click next.
  • Follow all the steps and provide all the information. End of these steps, you will get the “Measurement ID“.
  • Next, we will add the “Measurement ID” to the Google Tag Manager and connect with Google Analytics.

Install and setup Measurement ID to GTM

  • Go to the Google Tag Manager account. Click on the Tags link and click the New button.
  • Give a name of the Tag folder and click on the pencil icon.
  • It will pop up a new window, and click Google Analytics from there.
  • Next, click on the Google Tag link.
  • Paste the “Measurement ID” in the Tag ID field. Click the Save button.
  • Next, set up the “Triggering” section. Click on the pencil icon.
  • Click on the All Pages check box. Next, Click Add button and Save the settings.
  • The setup is done.

Test and publish the task

  • Although, the setup is done, we need to test and publish the task. We will complete them in the following steps.
  • For the test, Select the Tag and click on the Preview button.
  • We have to add our website name in the popup window.
  • For improving the debugging experience, we can install Tag Assistant Companion Browser Extension for Google Chrome. However, it is optional.
  • If everything is set up correctly, you will see a summary like the following screenshot.
  • Now, go back to the Google Analytics site and click on the Data display link. Click on the Debug View Link.
  • The debug view link will show you the result, like the following screenshot.
  • Now, everything looks fine. So, we can publish the settings from the Google Tag Manager. Select the Tag checkbox and click on the Submit button.
  • Note that it is a good practice to create/update tags by the version number or date. Here is an example.
  • You can also see the update from the dashboard.

Final result

You need to wait a few more days and allow analytics to collect data and generate reports for you.

, ,

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*

Back To Top