Install Google Analytics using Google Tag Manager


In WordPress Websites instead of Directly installing Google Analytics in your Website, you can use Google Tag Manager. And if you have much Analytics and tracking tags you can consider using Google Tag Manager.

If you install Google Tag Manager in your Website, you can add, edit, delete scripts from your Google Tag Manager, instead of modifying from your website.

From Google Tag Manager we can install a number of scripts by creating tags and can install Google Analytics, AdWords Tracking, Facebook Analytics. There are some pre-build tags that make it easy to install some tools, or can use Custom HTML Tag to add scripts that are not pre-build in Google Tag Manager.

install google analytics using google tag manager

So no need to modify your website each time when you plan to install some scripts tools. Setup as a tag in GTM. GTM loads those scripts Asynchronous ( it won’t stop other web assets to load until finishing the loading scripts )

Sign up for Google Analytics

( If you have already created a Google Analytics tracking code skip this step)

Navigate to Google Analytics and click on signup,

signup - form

Choose Website,

Account Name –  An Account can have multiple Properties, Apps, and in that properties, can have multiple Views. Properties & Apps are where the Tracking code exists.

Website Name  –  for reference – Enter a name which makes it simple to identify your web property

WebSite URL  –  Enter your website URL, if you are using HTTPS, Don’t forget to select https:// instead of HTTP.

Industry Category  – Choose the best option, but this is not mandatory and does not affect tracking and data collection.

Reporting Time Zone  –  Select your local time zone, so it makes you comfortable to understand the analytic reports.

create account - sample filled

And then at the bottom of the page – click on “Get Tracking ID

Google Analytics - Tracking code

Tracking ID  – UA-115775302-1   useful to add analytics using tools, GTM.

Global Site Tag (gtag.js)  – To add directly in your Website  ( we use GTM to add Google Analytics )

At any time to Get the Tracking code

Install Google Tag Manager

Navigate to Google Tag Manager

gtm create account

Account Name  –  Add Account name for Reference ( An Account and then Container and then Workspace )

Enter the Account Name and choose the Country and click on Continue.

gtm create container

Enter the Container name, choose Where to use the Container and click on Create,

gtm code

Add this Google Tag Manager code on your Website.

The first part of the code is mandatory. Try to add this in between <head> tag, as much as possible ( it will work even if you added it in body tag ).

And the second part is not mandatory, if the user disabled the JavaScript this will be useful.

Get Google Tag Manager Code at Any Time

Install Google Tag Manager code in WordPress Sites

It may be better to install using a plugin or if your theme provides a way to add Google Analytics or Google Tag Manager it will be the best choice to install.

To Add Google Tag Manager hard-coding

From the WordPress Admin / Dashboard

Appearance -> Editor -> header.php ( most themes add <head> tags in header.php )

gtm add in wordpress sites

Add “Script” part of the Google Tag Manager Code in head tag

gtm code - script tag

And add “noscript” tag part after the opening body tag, now Google Tag Manager successfully installed on your website.

Connect Google Analytics to Google Tag Manager

Now we need to Connect the Google Analytics to Google Tag Manager. So that GTM Will load Google Analytics code Asynchronous
from the Google Tag Manager Container.

gtm - new tag

Click on “Tags” from the left side menu

click on “New

gtm new tag configuration

click on “Tag Configuration” area and then click on “Universal Analytics

gtm add universal analytics

Track View – leave it as the page view, to track page views.

Google Analytics Settings  –  Select “New Variable“, this is where Google Analytics have to link. If already attached then select that variable.

gtm add google analytics variable

At the “Tracking ID” Add the Google Analytics Tracking ID.

Click on “Save”  ( Give a name to this Variable – something like  – your Google Analytics Tracking ID, or just give a name like Google Analytics Settings )

gtm all pages trigger

And then Click on “Triggering” Area

And Select “All Pages“, to trigger the event on All Pages ( or click on + to add Create new Trigger, All pages is build in Trigger ).

gtm add google Analytics on all pages

Almost Done, before “Submit” the changes its better to test,

gtm preview, submit

click on Preview ( at the top-right side ),

In the same browser in a new tab, open your website. At the bottom of your web page, you can check the details of the Google Tag Manager and how it works.

gtm preview , new window

check on page view – event/summary, for what tags are fired, and check what Variables are available, Data Layer.

once done click on “Leave Preview Mode“.

Go Live

go live - publish or save

To make the change work, click on “Submit” and at “Publish and Create Version” add “Version Name” and “Publish“.

To just save the changes but not willing to publish, “navigate to “Create Version” tab, add “Version name” and Create a Version.

After publishing the changes, you can view Analytics at Google Analytics Dashboard

Leave a Reply

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