Google Analytics is the most popular web analytics tool available at the moment. According to W3Techs, 55 percent of websites use Google Analytics as of December 2018 because it’s not only free, but also offers comprehensive data collection and analysis capabilities.
Google Analytics provides data about your site’s audience (what devices they use to browse your site, where they are coming from, etc.), acquisition (how are they coming), behavior (what they are doing while spending time on your site) and conversions (do they complete the goals set up by you?).
If you don’t know this data, it’ll be hard for you to picture what’s happening under the hood of your website. Is your site’s bounce rate high? How much time are visitors spending on the site? What are the most profitable traffic sources? Analytics data is the answer for all these questions.
Setting up Google Analytics isn’t a strenuous task at all. In this post we’ll show you the exact steps involved in the process, from creating an account to deploying the tracking code in the site.
Creating an account
First of all, you should have a Google account. Assuming you already have an account, you can log into it. If you don’t have one, just sign up for an account.
Side note – You may already have a personal Google account. But it’s better if you can have a separate account for your business and use it to create the Analytics account. It’s just a recommendation; there’s no harm in using your personal account if you prefer it.
Visit the Google Analytics web portal. Enter your account details and click ‘next’.
You’ll be directed to a page like below.
Once you click on the ‘sign up’ button on the right-hand side, you’ll come across a form like this.
- Google Analytics can be used to track data for websites as well as mobile apps.
- Provide a name for your account. You can name it as your business or organization name. One account can have multiple properties (we will discuss more details about account structures later). You can track different sites or sub-domains under one Analytics account as different properties.
- Mention the name of your website. This will help you to identify which of your websites is associated with this property. If you have only one site, then the name of it could be the name of the Analytics account as well.
- Make sure to select the right protocol, http or https.
- Category selection is not mandatory but it’s good to select the most relevant category. Google will provide industry-specific benchmark data for you to compare with your site’s data.
- Select the relevant time zone.
You’re probably planning or already doing paid advertising such as Google Ads or Facebook Ads. It’s important to make sure that the time zone you use in Analytics is the same as you use in the ad platforms. Otherwise, it’s difficult to carry out time-based analyses.
You might be wondering how this could happen, right? Imagine you’re based outside the U.S. but you’re starting a new ecommerce venture targeting the U.S. market. You set up the site and the Analytics account too. Since your target market is the U.S., you set the time zone of the Analytics account to one of U.S. time zones.
Then you start a Facebook campaign to drive visitors. But unfortunately, your FB ad account’s time zone is set to your local time zone. For this reason you may face difficulties when you are required to perform any time-based analyses.
Lastly, there are four data-sharing options which you can go through and decide whether to allow or not.
Once you click the ‘get tracking ID’ button, you’ll be prompted to accept the terms of service agreement.
Now you’re done with the account creation process and you’ll get the tracking code which has to be installed into your site in order to capture and send data to the Analytics account.
The tracking code is available in ‘Admin >> Tracking Info >> Tracking Code’.
Install tracking code in the site
The tracking code ‘Global Site Tag’ (gtag.js) has to be installed in the header section of your site so that it’ll be available in each and every page of your site.
If you have a static HTML site, then you can paste the tracking code into the file locally and upload it into the server using an FTP client.
Let’s see how you can install it if you are using WordPress as your CMS, which is likely the most common scenario. There are several ways to get it done.
Install using a plugin
Using a plugin is an easy and a reliable method to add the tracking code to your WordPress site. There are many plugins that could be used for this purpose, but we’ll demonstrate with the help of one called ‘Google Analytics Dashboard Plugin for WordPress by MonsterInsights’. It’s a popular plugin, and stats say that it’s being used by more than 1 million sites at the moment.
Firstly, install the MonsterInsights plugin. If you need any help in installing WordPress plugins, then read our post about it. Activate the plugin after the installation.
Upon the activation, you can see a new menu item called ‘Insights’. Go to ‘Insights >> Settings’.
Click the ‘Authenticate with your Google account’ button. You’ll redirect to a new page where you have to select, if you have already signed in, the Google account associated with your Analytics account and continue.
Next, you’ll have to allow the MonsterInsights plugin to access your Analytics data in order to complete the installation process.
Once you provide the permission, you can see the properties and views associated with your Analytics account. Select the correct view if you have multiple ones and complete the connection.
You’ll be redirected back to the WordPress dashboard.
MonsterInsights is not the only plugin that can be used to install Analytics in WordPress. There is a handful of other plugins which could be used to achieve the same purpose.
- Analytics Cat – This is a lightweight plugin designed specifically to add Google Analytics code to your site. It doesn’t have lots of features, but it provides an option to hide the tracking code from logged-in visitors so that you can keep your Analytics data clean. That’s an added advantage.
- Google Analytics Dashboard for WP – Apart from enabling you to add Analytics code into your site, it also helps you to view key stats within your WordPress dashboard. It’s even possible to track custom dimensions and events using this plugin. It’s a more advanced and comprehensive plugin.
- Insert Headers and Footers – This plugin allows users to add custom scripts to either headers or footers on WordPress sites. We can use it to add Analytics code as a header script using it. One main difference is that it’s not specifically designed as an Analytics implementation plugin.
Using WordPress theme options
Some of the WordPress themes provide the capability to include custom header and footer scripts via its options. For example, if you’re using the popular Genesis theme, you can include custom scripts easily.
Go to ‘Genesis >> Theme settings’. There’s a separate section for header and footer scripts. Copy and paste the global site tag into the header scripts section and save changes.
It’s better to check whether your theme provides this option. If your theme has it, then it’s much easier and safer to include the tracking code that way. More importantly, you don’t have to worry about it disappearing after updating the theme.
Installing directly in source code
If you don’t want to install any plugin or your theme doesn’t provide the option to include custom scripts, then you can directly embed the Google Analytics code in your site’s source code.
However, the tracking code will disappear when you’re updating the theme. To counter that, you should create a child theme and include the tracking code in it. It’s the recommended procedure if you want to go that path.
The pros and cons of using child themes and a brief guide on creating a basic one can be found here.
The tracking code has to be included in the header.php file. Navigate into ‘Appearance >> Editor’ and then select header.php from the list of files on the right-hand side.
As you can see in the above image, paste the code just before the </head> tag and update the file.
As you have seen, there are multiple methods to install Google Analytics code into your WordPress site. Once you’ve done that, then we need to make sure that Google Analytics is receiving the data.
Go to ‘Admin >> tracking info >> tracking code’ and click on ‘send test traffic’. If Analytics is set up properly, then you’ll see one active user from test traffic.
If you have set up tracking using a plugin which omits logged-in users’ data, then you may not see any real-time visitors if you test in the same browser. In this case, what you can do is open the site in a new Incognito window.
Then, go to the ‘Real-Time >> overview’ report in Analytics and you will see the visit in it.
You must use an analytics tool to gather and analyze data about your visitors if you have a website. It should be something that you do immediately, as soon as you start working on it.
Google Analytics is the most-used web analytics tool which is free and equipped with a great deal of functionalities.
Setting up Google Analytics isn’t a tedious task. It can be achieved quite easily, as we have shown above with our clear step-by-step instructions.