In this article I will show you my preferred method for installing Google Analytics on a website. Learn how to install Google Analytics using Google Tag Manager.
When I wrote an article about how to install Google Analytics on WordPress using a plugin, many asked me if that was the only or the best way to implement GA. As I mentioned in that article, there are several ways to implement the Google Analytics tracking code on a website, whether it be on WordPress or not.
In a hurry? Watch the video:
What is Google Analytics?
Google Analytics is the most popular and possibly the most comprehensive web analytics tool on the market. It is a free tool from Google (also available in the premium version with different features) to analyze the behavior of a website visitor.
It allows you to collect and analyze navigation data from visitors providing valuable insights for your business and digital strategy.
With GA it is possible to measure data such as number of visitors, page views, conversions, frequency and recency, sales, campaign results, events within the site and much more.
Read too: "Marketing metrics: partner metrics“
What is Google Tag Manager
Google Tag Manager (GTM) is a Google tag manager that aims to make life easier for any developer, marketer or website owner.
Through GTM we can implement tags not only for Google Analytics but also for Facebook, Google Ads, other analytics tools, etc.
Installing Google Analytics using Google Tag Manager
To use this method we must have installed GTM on our website. If you have not yet installed it, read the article “How to install Google Tag Manager on WordPress“. Even if your site is not in WP the reading is still valid and can help, since the concept to insert the GTM on the site is very simple.
This is my favorite method! Not only for its ease, but also for its possible customizations. Through this method you guarantee that your implementation will not be lost after an update or unwanted configuration change on the website.
The tutorial below assumes that you already have an active Google Analytics account or know how to create one.
Time required for this implementation: 5 minutes.
How to install Google Analytics using Google Tag Manager
- Create a Google Tag Manager account
Sign in to Google Tag Manager and create an account (if you already have an account skip this step).
- Install the GTM container on your website
Add the necessary scripts The
of your site as directed when creating the container. This procedure can be different or aided by the use of plugins in some CMSs.
- Configuring Google Analytics in Google Tag Manager
In the work area of your GTM container, go to variables and click to add a new variable. Enter the tracking id of the property you want to monitor.
- Triggering Google Analytics
Register a tag pageview to be triggered on all pages of your site (or just the pages you want).
- Post changes to your GTM
Click to publish changes to your container.
- Test your implementation
Always test your implementations to ensure that they are working and data is being collected correctly. To test this implementation, I suggest that you use the Google Tag Manager preview mode and also Google Analytics.
That's it! Now your site has Google Analytics installed through Google Tag Manager.
It should be noted that the configuration presented in this tutorial is the most basic possible. Both the Google Analytics configuration and the pageview tag (and other tags) can be subject to numerous customizations according to the interests of your business.
Adding Google Analytics through Google Tag Manager is a fast and secure way to implement GA.
Using GTM it is possible to customize the GA configuration in numerous ways, thus collecting data that can be used for the growth of your website, blog or online store.
Keep reading: "Analytics tools: 5 reasons not to use them“
Keep reading: "Digital Marketing Metrics: Which Are Important?“