Google Analytics (GA) is a free service that will provide you with tons of data and insights that will be really helpful to grow your traffic and conversions.
A word about speed, some people might tell you that adding this code will slow down the speed of your pages, which is the opposite Google likes, but rest assure this is not the case! This type of code will not affect your pages/website speed.
When is the right time to add Google Analytics to my website?
As soon as you have your website ready to go live.
Installing Google Analytics
You can install Google Analytics (GA) with and without a plugin. Iʼm going to cover both ways step by step. If youʼre more advanced, after creating your Google Analytics account, skip how to install it and jump to the section on Google Tag Manager (GTM).
First, you need a Google Analytics account.
Create a Google Analytics Account
Go to: https://marketingplatform.google.com/about/analytics/
Choose from the menu on the top “Sign In with Analytics” to create your free account.
Youʼll need to enter your information next:
Tracking Method – choose Website
Account Name – enter something descriptive
Website Name – enter your website name
Website URL – enter www.yourwebsitename.com or if youʼre not using www, enter yourwebsite.com
Industry Category – choose the industry where your website fits best
Reporting Time Zone – this is important! This sets the time zone you want to use as the day boundary for your reports, regardless of where the data originates. For example, if you choose United States, Pacific Time, then the beginning and end of each day are calculated based on Pacific Time, even if the hit comes from New York, London, or Moscow. So set it in a way that will reflect the reality of the audience youʼre targeting, so you wonʼt end up seeing part of your traffic on the wrong day in the report due to the time zone settings.
Data Sharing Settings – Youʼll see different options here and you can
decide what you want to share or not:
Google Products and Services – is the most important one because if you want to integrate with services like Adwords or Google Console, youʼll need to check this box or you wonʼt be able to integrate other services.
Benchmarking – check the box for this option if youʼd like to use anonymous data to compare your website to other sites in your industry.
Technical Support – check the box for this option if you might need technical support in the future.
Account Specialist: check the box for this option if you might need support by a Google Analytics account specialist, because theyʼll only be able to access your data, to help you, if you check this option.
Finish up by hitting the button Get Tracking ID and youʼll see a pop up with Google Terms of Service. Make sure to read it and if you accept it, click the button at the end “I accept”.
And youʼll find yourself inside your new Google Analytics!
It automatically shows you the Admin panel, and you can see it includes a menu that says Tracking Code. This is where you get the code youʼll need to add to your website. Letʼs look at the information this section is showing.
Tracking ID – this is made of 3 parts: the letters UA (Universal Analytics, the old name of Google Analytics), a number with several digits, and the last part is the order number for the websites that you have in your account. This being the first website youʼre adding to your Analytics account, youʼll see the number 1, so your Tracking ID should look like this: UA-123456789-1
Now this Tracking ID by itself is not enough for Google Analytics to work.
You need to copy the full tracking code as Google shows you:
You need to carefully copy the code below this information as youʼll need to paste it into the <head> code of your website. This tracking code will need to be on every single page of your website so Google is able to get all the information it needs, so we need to add it in a global way to your website, not page by page.
So copy your tracking code that looks like this:
<!– Global site tag (gtag.js) – Google Analytics –>
<script async src=”https://www.googletagmanager.com/gtag/js?id=UA123456789-1″></script>
<script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag(‘js’, new Date()); gtag(‘config’, ‘UA-123456789-1’);
</script>
Installing Manually the Tracking Code on your website
You can install the Tracking Code manually or using a plugin.
Letʼs first see how to do it manually. Youʼll need to add the Tracking Code to the header.php file of your website.
To do this, login to your WordPress dashboard and navigate in the left menu to Appearance, then choose Theme Editor. Then on the right, youʼll
see Theme Files, click on the one named Theme Header →> you can see it highlighted in the screenshot below.
Paste the tracking code you just copied from your Analytics profile before the closing </head> tag → you can see exactly where in the screenshot above, highlighted on the left. A quick tip: we know itʼs a closing tag because it has a “/”, like this </head>.
Then click Update File and you’re done. Google Analytics is ready to work for you!
What if I don’t want to touch “code” at all?
Good news! There are WordPress plugins that allow you to add Google Analytics with a single click, you’ll just need to enter your Tracking ID (ex: UA-123456789-1) and it will handle the rest.
I recommend you use the plugin “Google Analytics Dashboard Plugin for WordPress by MonsterInsights”.
This plugin Lite version is free and you have a paid version that has extra features and support. We saw in lesson 4 of this module how to add a plugin to your website, so go ahead and after installing and activating this plugin, go to Settings and at the bottom, youʼll see Setup Wizard.
Just follow the steps as asked. Youʼll need to have handy your Tracking ID to enter when requested and this is a simple way to get Google Analytics installed without having to deal with code!
Then you can check out the free courses Google offers on using Google
Analytics here: https://analytics.google.com/analytics/academy/
Google Tag Manager
The Google Tag Manager (GTM) is a third option for adding Google Analytics to your website, it requires you to add code not just in the head section but also on the body section and there are more Settings to
set, so is a good option if you’re a bit more advanced. If you’re a beginner, you can always upgrade to GTM later on.
Please note that you install the Google Tag Manager code OR install the Google Analytics code, donʼt install both codes!
The advantage with GTM is that allows you to add tracking tags for multiple analytics, paid media and tools in one interface. You’ll be able to integrate 3rd party tools like Hotjar (heat maps) and other cool platforms.
To sign up for GTM go to: https://marketingplatform.google.com/about/tag-manager/
You’ll be asked to enter some information to set up your account:
Account Name – this can be for example your website name
Country – choose the country youʼre operating in
Share data anonymously with Google and others – check this box if you’d like access to benchmarking information to compare your site
Container Name – enter your website, like this www.yourwebsite.com (or
yourwebsite.com if you aren’t using the www)
Target Platform – choose Web
Hit the Create button
Review Google Terms of Services and if you agree with it, click Yes.
Then youʼll see a pop up with your Tracking Code. Itʼs two pieces of code, one to go in the <head> section and another to go into the <body> section of your website. Copy both and save it.
Next, you need to Create a New Tag.
Click on Add a new tag
At the top, change Untitled Tag for a tag name, for instance, Google Analytics.
Next click on the grey icon where it says Choose a tag type to be setup
and you’ll see a list of Tag Types to choose from, choose Google Analytics – Universal Analytics.
Now you’re seeing the Tag Configuration panel.
Tag Type is Google Analytics.
Track Type – make sure it is set for Page View.
Google Analytics Settings – Choose New Variable from the menu And it will open a new panel like this one:
Change Untitled Variable at the top to for ex. Google Account Analytics ID.
Enter in Tracking ID your Google Analytics Tracking ID that you got when you created your Google Analytics account and looks like this: UA123456789-1 And hit Save.
Next, letʼs create your Triggering.
Click on the grey icon above Choose a trigger to make this tag fire…
Youʼll see thereʼs only one trigger in there by default – All Pages.
Click on All Pages to select it and set that as your trigger.
Click Save on the top right of the page and youʼre almost done.
Now assuming you added to your website the code as weʼve seen is required for GTM to work – if you still need to do that, you can grab the code by clicking on the top menu where it shows your GTM ID in the format of GTM-XXXXXX – weʼre almost done.
Hit the Submit button at the top right to the page
Enter a name for Version Name, for example, Added Google Analytics, hit Publish and youʼre done!