For WordPress beginners learning how to install Google Analytics on WordPress can be difficult. In this article we will outline the steps to getting Google Analytics installed and operational.
Google analytics is a great free tool which allows easy tracking and evaluation of user traffic to your website. To find out more about Google Analytics and the features it offers read our Intro to Google Analytics article.
Google Analytics Account Setup
First you will need to create a google analytics account. This is done by visiting Google marketing suite and creating a Google Analytics account:
If you have an existing Google Account you can use this to sign in or you will need to create a new Google Account to access analytics.
Once you are logged-in you can create your new Google Analytics account. Note: Within the Google Analytics application, it is structured in the following way:
Managing the structure of your Google Analytics account is very much up to your specific organization. Google has provided some helpful definitions of the structure and options on setup: https://support.google.com/analytics/answer/1009618?hl=en#Accounts
New Google Analytics Account
Once you have signed in to Google Analytics you will be asked to setup a new account.
- What would you like to Track? You can choose either a Website or Mobile app.
- Now enter your account name, in most cases this is the business/organization name
- Next you will be asked to setup your property, this is the name of the application or website you would like to track.
- Next you will be asked for the URL of the website you would like to track. Note: ensure you enter https if your website has a SSL certificate installed.
- Next select the relevant industry category
- Next set the reporting time-zone you would like to set on the account.
- Google then asks what data you consent to sharing with them. Again this is very much up to the policy of your organization. Select/Deselect the options relevant for your company.
- Select the “Get Tracking ID” button
You will now be taken to the Tracking Code view with the Track ID number on the top of the screen along with the Global Site Tag (gtag.js) code. Copy and save the code presented which will look something like:
How to Install Google Analytics on WordPress
Now that your Google Analytics account is setup along with the new website property, you need to add this to your WordPress site.
There are two easy ways this can be done:
- Most themes have the option of adding Google Analytics code to them in the Theme customize or control panel. Ensure you have thoroughly reviewed your themes documentation to see if this is an option.
- The second simple option is to use the WordPress plugin “Insert Headers & Footers” https://wordpress.org/plugins/insert-headers-and-footers/
We will cover how to setup using the second option.
In the new tab you just opened login to your WordPress admin panel and:
- Navigate to the plugins tab and select “Add new”.
- Search for new plugin “Insert headers and Footers”
- Install and Activate the plugin
- Navigate to the Settings menu item and locate “Insert headers & footers”
- Copy the Global Site Tag you were given from Google Analytics and paste into the scripts in header code block.
- Select Save.
You will now need to ensure the code has been installed correctly and is tracking users. To do this, navigate to the front-end of your WordPress site and scroll down the page.
Navigate back to the open Google Analytics tab. In the left-hand-side menu select the clock icon, “Real-Time > Overview” Report. You should then see 1 active user on your site if the tracking has been implemented correctly.
You are now setup and tracking website traffic to your WordPress site.
It is also important to filter out internal traffic to your website, to ensure you are not artificially inflating your numbers. For more on how to exclude this data from your property see our article – How to exclude your IP Address from Google Analytics.