Hosting Tutorial & Guide

How to Add and Set Up Google Analytics for Your Website

updated on Jul 18, 2017
How to Add and Set Up Google Analytics for Your Website Have you ever wanted to know how many page visits you get? Have you ever wanted to track what visitors do and where they come from on your website? If so, you may consider using the freemium software service – Google Analytics.

However, there are still many people getting confused by the thought of using Google Analytics. At this place, we would like to showcase the importance of this analytics software and all needed steps to get it started on your website. Drop down and continue reading more details.

Why Is Google Analytics Important?

By all accounts, it is of great value to know how your visitors interact with your website. Google Analytics, as one of the best analytics service of Google, is such a useful tool used to track and analyze a website's traffic. As is noted above, this statistics service rocks by helping you keep track of:

When your scanners come – You are able to look at the most popular hours of your website and hence schedule your post accordingly.
Where your readers are from – You will also become aware of where your target audiences come from, such as direct links, search engines and referral links, etc. More importantly, you can take a closer look at the break-down categories for those traffic resources.
How your visitors react to your content – You can see how visitors like your content and website links most. And then, you are capable of adjusting and re-building link strategies for better performance.
Who scans your website – You can get to know your visitors' locations and their browsers used to visit your website. In the meantime, you will see other important information, such as Flash, JavaScript support and screen resolution, etc.
What your audiences do on your website – You will be aware of where your audiences are going to and how long they linger on your website. Also, you can know the bounce rate which refers to the percentage of scanners who leave your site on the first visit.

How to Set Up Google Analytics?

To put Google Analytics onto your WordPress site, you need to set up Google Analytics in advance. To do this, you may refer to the following steps.

Register a Google Analytics Account

To sign up a Google Analytics account, you need to visit this Google Analytics Sign-Up Page. As is showed in the following image, you will only need to enter account and password to log in, on condition that you have a Gmail account already. If not, you shall create a Gmail account firstly.

How to Set Up Google Analytics

Once done, you will need to go to "Sign Up" to register for Google Analytics, which is totally hassle-free.

Choose Your Analytics Account

On the editing page, there are two tracking methods, including Website and Mobile App. That is to say, you are prompted to make a choice between the two options. Here, you shall select the website option.

How to Set Up Google Analytics

At the same time, you will encounter "Universal Analytics" and "Classic Analytics" accounts. Note that the Universal account is in beta and consists of more features than that of the Classic one. On the other hand, if you choose the Classic account, you are still allowed to upgrade to new functionalities and features.

Enter Some Necessary Information

Then, Google will prompt you to fill in general information, including account name, website's URL, country and time zone. Also, you can decide whether to share Google Analytics data with others by making settings in the "Data Sharing Settings" section. At last, make sure that you have agreed the "Terms and Conditions", and click "Create Account" to go on.

How to Set Up Google Analytics

Copy and Paste Tracking Code

If done, you will be switched to a new page where you can see the tracking ID and code. All you need to do is to copy and paste those codes to your WordPress site. Considering that you will revisit this page, you'd better not close this browser tab.
As is displayed in below, you will be given a series of JavaScript codes as follows.

How to Set Up Google Analytics

How to Add Google Analytics to WordPress Site?

Having done with the mentioned steps, you should add Google Analytics to your site by using the provided tracking code. To achieve this goal, you can choose to add those codes to the header.php file, functions.php file or a plugin's setting page. In the following part, we will have a brief look at those methods one by one.

Apply Tracking Code to Header Directory

Here, you need to go back to the dashboard of WordPress and go to "Appearance > Editor". Then, find out the "header.php" file and paste the offered tracking code after <body> tag. Do not forget to "Update File" to save all changes.

How to Set Up Google Analytics

Add Tracking Code to Functions.php File

Alternatively, you can choose to access the server and add those tracking codes to the "functions.php" file under the "themes" directory. Remember to paste the following codes at the same time.

add_action("wp_footer", "add_googleanalytics");
function add_googleanalytics() 
    //Paste your tracking code here

To enter the "funtions.php" file, you shall firstly go to the /themes/ under the directory of /wp-content/. Then, find out your current theme's directory (such as, twentythirteen) and select the "functions.php" file. To be frank, this method is not recommendable for newbies who are not familiar with coding stuff.

How to Set Up Google Analytics

Put Tracking Code in Plugin's Setting Page

As a leading content management system, WordPress has plenty of Google Analytics plugins for you to choose from. Whichever one you decide to use, you should go to this plugin's editing page to paste the code there. In terms of plugin installation and activation, you can refer to this tutorial.

Check Whether Google Analytics Is Working

If done, you shall go back to the Google Analytics browser tab and click "Save" button to put it into effect. To check whether it is working, you will need to go to "Admin > Tracking Info". If the "Tracking Status" is set as "Receiving Data", then you can be sure that Google Analytics has been added to your website successfully.

How to Set Up Google Analytics

In the further, you will need to click the "Reporting" button lying on the top of the page to have a look at your site's analytics overview. Note that Google usually takes 12-24 hours to generate website stats.

How to Set Up Google Analytics

Summary - Recommendable Web Hosting Solutions

To sum up, making use of Google Analytics to interact with your audiences is a great way to boost site traffic and SEO ranking. In the further, a reliable and responsive online environment is also crucial to your website performance. For your convenience, we have researched and selected the following recommendable web hosting solutions, all of which are outstanding in reliability and speed.