What's WP
Our everything is about WordPress - best choice of WordPress users!
How to Add Google Analytics to WordPress for Website Tracking

How to Add Google Analytics to WordPress for Website Tracking

We have already shared a lot of useful tips helping you increase the traffic of your site easily, such as social media marketing and keyword research. However, how do you estimate the value these tricks put into your site? After all, you need to keep tracking the site traffic, and then optimize the website accordingly. In this case, the powerful tool of Google Analytics can come into play.

Google Analytics helps users analyse visitor traffic, including who visits the site, what they do, when they visit, where they from and what content they are interested in. It is the best way to show customers’ preference through ads, videos, websites, social tools, and smartphones, which makes things much easier to serve for the existing customers and attract new ones. In below, we come out the detailed tutorial to guide you add Google Analytics to WordPress websites for traffic monitoring.

Why Use Google Analytics

This tool is an online service offered by Google, which is used to monitor the traffic of a website and generate the detailed statistics for users. It allows webmasters to know the daily views, traffic source, and conversion rate clearly via a lot of objective referrers like search engines, social networking platforms, and some referring sites.

With it, you can

  • Have an insight of grow pace of your website.
  • Have a complete picture of your audience and their needs.
  • Know the devices and routes that take people to your site.
  • Know how people interact with your posts.
  • Track multiple websites at one time.
  • Keep pace with your site without spending even one penny.

Sign Up A Google Analytics Account

First of all, you need to create a Google Analytics account.Visit the home page and you are required to sign in Gmail account. If you don’t have one already, you need to create an account for yourself, which is available for all Google products like YouTube, Gmail, Google+, etc. One the other hand, you can sign in directly if you already have a Gmail account.

sign in Gmail account

Then, you are linked to the next page like the following one, where you can feel free to sign up Google Analytics, it’s easy and free! Click the Sign Up button, it will automatically sign up Google Analytics with your Gmail account.

sign up Google Analytics

Now, it’s time to create a new account. You are able to choose what you would like to track, a website or mobile app. In order to install Google Analytics in WordPress websites, we select Website in this step.

As well, you can also select a tracking method as Universal Analytics or Classic analytics to track your website. The only difference is that Universal Analytics is in beta and comes with extra features and a Classic Analytics account. You are free to choose either of the two methods. Even if choosing the Classic Analytics, you will be upgraded to new features once needed.

tracking method

Now, you can be directed to a page that requires you to fill out the account information, which includes the account name, website URL, time zone, and contact information. After completing these blanks, you need to accept the Terms and Service.

google analytics account

Now, you have created a new account successfully. The next thing you need to do is getting Google Analytics tracking code. You can be led to the right page immediately after the account creation process. In this page, you can decide whether to track a single domain or multiple top-level domains. After deciding this, there will be lines of HTML code available in the right side. Copy it immediately.

tracking code

Install Google Analytics in WordPress

We have prepared everything already, and it’s time to install Google Analytics in your WordPress websites. Briefly, there are 3 typical methods: plugins, direct paste code and functions.php. In the following, we explain every method carefully, and you can choose the one you like best.

Install Plugin

There are thousands of plugins available for installing Google Analytics in WordPress websites. However, it is better choose the best statistics plugin reviewed by both users and experts. Installing the plugin, you just need to paste tracking codes in the plugin’s setting page and Google analytics will track your website automatically.

Paste Tracking Code

If you don’t want to install extra plugins, you can directly pastes tracking codes into your themes. Login into your dashboard, go to Appearance -> Editor, find header.php File and open it, then paste tracking codes right after thetag.

Edit function.php File

For webmasters who prefer coding stuff, they can install Google Analytics by adding the following code into function.php File. Note that only use this method if you are clear what you are doing.

add_action('whatswp_footer', 'add_analytics');
function add_analytics() { ?-->
// Paste your Google Analytics tracking code here
<!--?php } ?-->

Remember to add your tracking code in the right place.

Start Tracking

Still now, you have done all the steps and installed Google analytics in your website successfully and can start tracking your site with a precise analysis. You can click the Reporting tab to see your website’s analytics overview. With the reporting, you can also learn about all visits, new visits, unique visitors, visits by browser, bounce rate, revenue, and so on.

start tracking

In fact, there are also a few things you need to do for better convenience. In the dashboard of Google Analytics, you can see a lot of reports concerning about different parts. Simply choose the type of data you need the most from the left column, and click the button of Add to Dashboard. Thus, you can check it on the dashboard and decide the position as you wish by dragging it.

Besides, you can also decide the time range. You can track your site daily, weekly, monthly or whatever you want. Simply click date range box, and do some configurations based on your needs. If you want to compare date range, you can check the box before “compare to post” in this calendar page.

time range

Useful In-built Features

After presenting how to use this tool basically, we’d like to show some advanced options in the following.

Site Speed – There is no need to emphasize the importance of the page loading speed as it determines the quality of reading experience largely. You can check the detailed data from Google Analytics in seconds.

speed tracking

Event Tracking – Knowing what visitors have done with your site makes it easy to know their ultimate needs. With this advanced feature, you can get the clear information of what happened between your visitors and websites, and how many people have done the same things.

event tracking

Real Time Report – For people who are targeting foreign visitors, seeing the traffic of some specific moments is important. After all, they need to figure out the best time to publish posts for more page views easily.

real time tracking


Joyce is a professional writer & SEOer who loves trying new things and sharing the experience through blogging. She loves clean design, playing with different WordPress themes, SEO, etc. Now she is very struggle with purchasing a bubbling apartment in downtown. You can help her by clicking our ADs or making a purchase via our links ;-)


Want to Learn More About WordPress?

Get Our Free Themes, Plugins, Support, SEO Tips, and Other Tutorials!

Email *