Install Google Analytics using Google Tag Manager

Install Google Analytics using Google Tag Manager, in WordPress Websites Instead of Directly installing Google Analytics in your Website, use 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. one time installed Google Tag Manager in your website – and from Google Tag Manager can install a number of scripts by creating tags Can install Google Analytics, AdWords Tracking, Facebook Analytics. They are some pre-build tags which makes 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 finish loading this scripts )

Sign up for Google Analytics

( If you already created 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 is where 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  – not mandatory, select the best match, this does not affect tracking and data collection. Reporting Time Zone  –  Select your local time zone, so it make you comfortable to understand analytics report.
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 ) Did you noticed the Google Tag Manager Suggestion given in this page, if you have much analytics, tracking tags, consider using Google Tag Manager Instead of adding Google Analytics directly on Website, We will use Google Tag Manager to install 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 in on your Website The first part of the code is mandatory Add this in between <head> tag, as high as possible ( it will work even if you added in body tag ) And the second part is not mandatory, in case user disabled 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 Installed Successfully on 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 the 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 it 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 change but not willing to publish, “navigate to “Create Version” tab, add “Version name” and Create a Version. After publishing the changes, Can view Analytics at Google Analytics Dashboard

Leave a Reply

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