If you want to run a successful website, it is essential to know your audience and what they expect from your site. The best way to achieve this is by analyzing your traffic. That’s exactly what Google Analytics does. This free software from Google allows you to track your website’s visitors, analyze their habits, traffic sources, social metrics and a lot more different statistics. By analyzing statistics, you can plan and create better content for your readers. This tutorial will show you how to sign up for and add Google Analytics to your WordPress website.
Table of Contents
Why Do You Need Google Analytics in Your WordPress?
Things are pretty easy when you know what your users want from you, your website and your services, aren’t they? The only way to make your visitors stick to your website time and again is by providing them what they need. This is exactly what Google Analytics does for free! Here are a few reasons why we would suggest you to add Google Analytics to WordPress and feel that every WordPress blog must have it:
- Helps you in determining your users’ behavior.
Yes, you can virtually keep track of your visitors’ behavior with Google Analytics. You can easily check the most viewed pages, the average time each user spent on a certain page, the top performing pages, as well as detect the page that causes your visitors to exit your website and a lot more. It goes without saying that having a quick look at such information would help you in better optimizing your website. If a certain blog post is driving the most views, you could write more blog posts on related topics and attract more traffic.
- Helps you in analyzing the most active time.
You can easily determine the hour at which you get the most traffic. If most of the users are active at night, it is obvious that in order to catch more views, you should schedule your posts to go live at the late hours.
- Helps you in exploring the crucial details.
Google Analytics can provide the tiniest details – from the geographical location of any user to the language they speak, the browser they use, the screen resolution and the likes. Thus, it helps you understand your audiences better.
Although there are quite a few other web analytics services you can use, Google Analytics provides a range of exclusive features. Let’s have a quick look at each of them:
- Generate Custom Reports easily.
The best way to analyze your users’ behavior is by making use of facts and figures. This could be easily done by generating custom reports with an easy to understand interface. You can add various parameters and metrics in order to generate an insightful report.
- Set up Custom Alerts.
This is a truly awesome part of Google Analytics with which you can send a custom alert in the form of a text message or an email each time there is a sudden dip in traffic or a drastic change in the bounce rate. Thus, you no longer need to keep your eyes glued to your dashboard to catch important updates.
- Integrate Search Console.
Keeping a sharp eye on SEO related stats and figures is important. Search Console is one such tool which would provide you the information related to search engine optimization. Integrating Search Console with Google Analytics would make the information easily accessible under one roof for quick analysis.
These are just a few of many Google Analytics features which make the entire process of handling a WordPress website easy-breezy!
How Does Google Analytics Work?
You may already think that Google Analytics is amazing. But how does it do it all? Well, we understand that having a basic knowledge of how the software works helps in making the most out of it. Speaking broadly, Google Analytics consists of:
- Data collection service
- Data processing
During data processing, Google Analytics servers turn raw data into useful information. For example, categorize your visitors based on their location, language, screen resolution, device type and so on.
This is how it works. It might seem like an easy process at first, but a whole lot of functionalities and processing is going on behind the scene.
We hope this surely strengthened the decision to add Google Analytics to your WordPress website. Without beating around the bush any further, here is a quick tutorial which will show you how to sign up for and add Google Analytics to your WordPress website.
What you’ll need
Before you begin this guide, you’ll need the following:
Step 1 – Creating a Google Analytics Account
The first thing you need to do is create a Google Analytics account and obtain the tracking code. The steps below show how to sign up for Google Analytics:
- Start by navigating to Google Analytics home page. Press the Sign In button, which is located at the top of the page and select Google Analytics.
- You will be redirected to the Login page. Enter your Google email address and press the Next button. If you don’t have a Google account yet, create one by pressing the Create Account button.
- On the next page, enter your password and press the Sign In button.
- Press the Sign Up button in order to proceed.
- In order to create a new account, you will have to enter the following information:
- Account Name.
- Website Name.
- Website URL.
- Industry Category.
- Reporting Time Zone.
Fill all the required details and press the Get Tracking ID button (6). On the next page, you will be asked to accept the Terms of Service, so click the I Accept button.
That’s it! You have successfully created a Google Analytics account. On the next page, you will see the Google Analytics Universal tracking code:
Step 2 – Adding Google Analytics to a WordPress Blog
There is more than one way to add Google Analytics tracking code to WordPress: by using a Plugin, by adding tracking script directly to the header.php file or by creating a new action in functions.php file.
Option 1 – Using a Plugin
If you are not familiar with WordPress file structure and PHP, it’s recommended to use the Plugin method. One of the best plugins for this is Analytics Code Integration. This plugin will insert the Universal Analytics tracking code automatically – you will only have to enter your tracking ID.
Looking for a better way to host your website?
Transfer your website to the fastest web hosting platform with 24/7 dedicated support.
The steps below show how to install the plugin and insert the Google Analytics tracking ID:
- Log in to WordPress Dashboard and install the Google Analytics plugin. Follow this tutorial if you are not sure about how to install new plugins on WordPress.
- Once the installation is complete, navigate to the Settings section and press on Google Analytics.
- Scroll down to Plugin Settings and insert your tracking ID.
- Press Save Settings and that’s it, the tracking code has been successfully added to your WordPress blog.
Of course there are many other WordPress plugins (see a roundup of the best Google Analytics Plugins for WordPress here) you can use to. All of them serves the same purpose and can further enhance your experience.
Be advised that it can take 12-24 hours for Google Analytics to update and start showing first results. Afterward, statistics about your audience will be provided in the Google Analytics Reporting tab.
Option 2 – Inserting Code to header.php
As we said, there are a few ways to insert the Google Analytics code to a WordPress blog. For example, the code can be included in your theme’s header.php file:
- Access the WordPress administrator area and navigate to Appearance -> Editor.
- Open header.php for editing.
- Insert the Analytics tracking code you acquired in Step 1 before the closing
</head>tag and press the Update File button.
Note: Analytics code will be inserted only to your active theme. You will have to add it again if you change the theme.
Option 3 – Creating a New Function in functions.php File
This method requires some basic coding knowledge and we would highly recommend you to follow it only when you are confident in what you’re doing. Moreover, it’s strongly recommended to create a backup of functions.php file or even your whole WordPress installation before proceeding:
- While in WordPress dashboard, navigate to Appearance – > Editor section.
- Select functions.php from the list of files on the right.
- The following code snippet will create a new function and insert the Analytics tracking code just before the closing
</head>tag in your WordPress site. Paste this code at the bottom of the functions.php file, but be sure to change your tracking ID.
- Save the changes you’ve made by clicking the Update File button.
Note: The code will be inserted to your active theme only. If you change your theme, you will have to re-add the code again.
Needless to say, Google Analytics is essential for your WordPress website in order to understand your audiences better. By finishing this tutorial, you have learned how to create a Google Analytics account and three different ways to add Google Analytics to your WordPress blog.