How to Set Up Google Analytics in WordPress?

How to Set Up Google Analytics in WordPress

Wondering how to set up Google Analytics in WordPress?

Now that you’ve your website up and running, it’s time to start growing your website.

To truly know how successful your website is, you’ll need to track your website metrics and data.

The best way to know how your visitors interact with your website is through your web stats and traffic.

You can easily do that with the help of Google Analytics.

What Is Google Analytics?

Google Analytics is the most popular and free website analytics tool that provides enormous streams of data to improve your small business.

Google Analytics allows you to track your website analytics such as –

  • How much traffic your website gets?
  • Who is visiting your website?
  • What pages are they looking at?
  • How do people find your website?
  • Where your traffic is coming from?

This detailed reports can help you better understand your audience, make important decisions and find a new solution to sell more products, grow your email list and much more.

Why is Google Analytics Important for Bloggers?

Once you start a blog, your #1 goal is to get more traffic and subscribers.

Google Analytics help you make data-driven decisions by showing you the stats that matter.

You can see…

Who visits your website?

This part of analytics answers what is the geographical location of your audience, which browser did the user use to visit your site and other important information such as screen resolution, JavaScript support, Flash support, language and more.

This data is extremely useful, and it can help in numerous ways.

When getting a custom design, you can use the user data to make sure that your site will be compatible with your audience.

If most of your users don’t have Flash support, then you should avoid adding the flash element in your site.

If most of your users are on 1280 screen resolutions, then make sure that your design is compatible with that resolution or smaller.

What do people do when they are on your website?

You can track where the users are going on your website, how long do they stay on your website, and what is the bounce rate (the percent of users exit your site on the first visit).

By using this information, you can decrease the bounce rate and increase your page views.

You can also find your most popular articles, articles that are not doing so well, and what kind of content your users are looking for.

When do people visit your website?

By looking at the hottest hours in the day for your site, you can pick the time when you publish your post.

If that time zone is not compatible with yours, then you can schedule your post to meet that hour.

How do people find your website?

This section of the analytics shows you where did the users come from (for example Search Engines, Direct Links, Referral links from another site).

It also shows you what percentage of your visitors came from each of these sources.

Google Analytics gives you the breakdown of each of these categories.

If it is the search engine category, then it shows you which search engine got you the most traffic, Google, Yahoo, Bing, etc.

The breakdown of referral sources shows you which sites you need to work with the most.

If your top referral source is Facebook, then you need to have exclusive Facebook content to make your Facebook audience feel special.

If your top referral source is an external website, then you might want to consider having a partnership with that website (guest post exchange or something else).

How do people interact with your content?

Google analytics shows how your users interact with your site’s content.

It shows you what percent of the user clicked on which link on your site and much more.

You can run A/B split tests by creating content experiments in Google Analytics to understand what works best to meet your goals.

By seeing the user interactivity, you can work your content around your users.

By seeing the answers to the questions above, you can focus on the strategies that work for your site and avoid strategies that don’t work.

Simply put, eliminate the guesswork and focus on stats that matter, so you can make data-driven decisions.

Is It best to add Google Analytics with or without a Plugin?

You might think that the fewer plugins you use on your site the better, but that’s not always necessarily true.

It’s true that badly coded plugins could add bloat and slow down your site.

But a well-made, lightweight plugin can save you a lot of time and hassle, without any ill effects.

In fact, the number of plugins on a WordPress site has actually next to no direct correlation with your site’s speed and performance.

It’s all about the quality of the plugins installed.

Top WordPress plugins, like MonsterInsights, which have millions of installs, are more tested and optimized for speed.

They have no impact on site load speed whatsoever.

You can read more about how plugins affect your site’s speed here.

Before we jump in, let’s take a look at why adding Google Analytics to your site without a plugin may not be the best choice for your site.

  • Not as easy: Adding Google Analytics to your site without a plugin is not as easy as with a plugin. With MonsterInsights, the best Google Analytics plugin for WordPress, you can easily set up Analytics with just a few clicks.
  • You may lose tracking code: When you switch your themes, you may forget to add the Analytics tracking code again to your new theme. In the period of time before you add your tracking code again, your visitors won’t be tracked. With a plugin, you won’t miss out on that data.
  • You miss powerful Analytics features: You’ll miss powerful features like events tracking, custom dimensions, file download tracking, and more. Without a plugin, it’s very time consuming to set up these features on your WordPress site.

How to Signup with Google Analytics?

Google Analytics is available for free and all you need is a Google or Gmail account to sign up.

The signup process is quite simple, follow the step by step instructions below to create your Google Analytics account.

You’ll need a Google account to add Google Analytics to your website.

To do this properly, you might want to use a separate Gmail account, especially for your blog.

If you don’t already have one that you’re comfortable using for your website, you can create a new account here.

If you already have a Google account, then you can use that to sign-in.

Once you’ve signed in to your Google account, go to Google Analytics page. You’ll come to a page like this.

At the top right corner of the page, click “Sign in” and choose “Analytics

Next, you will see a page like the one below where you’ll need to sign up for Google analytics with your Gmail account.

To get started, click “Sign Up”, fill up all the information and settings for the website you want to start tracking.

At the top of the page, you can see there are two options given: Website and Mobile app.

Google Analytics works for both website and mobile apps but the tracking method is different.

In this tutorial, we want to set up for a website, so make sure you select “Website”.

Next, you’ll need to enter a name for your Google Analytics account and enter your website name, URL, category, country, and your time zone.

After entering all the details required, scroll down the page and you will come to this Data Sharing Settings section.

Read through it and check the boxes if you agree to share your data with Google, their support team and account specialists.

If you’re not ready to share any data with Googe, you can leave the options blank.

After selecting your sharing options, click the “Get Tracking ID” at the bottom of the page.

Then, a popup window will appear for you to review the Google Analytics terms of service.

You must agree to the terms in order to proceed, so click on “I accept”.

You’ll be given a Google Analytics tracking code. You might need to paste this tracking code into your WordPress site if you’re using method 2 below.

That’s it! Now you have set up a Google Analytics account, it’s time to install the code on your website.

How to install the analytics code on your WordPress site?

There are several different ways to install the analytics code on your WordPress site.

I’m going to show you 3 easy methods:

  • Google Analytics by MonsterInsights plugin
  • Insert Headers and Footers plugin
  • Without Plugins

How to Install Google Analytics Using MonsterInsights

If you’re using WordPress, one of the best ways to install analytic code on your site is using Google Analytic by MonterInsights, formerly known as Google Analytics by Yoast.

MonsterInsights offers both a free and Pro version. In this guide, we’ll be using the free version.

The setup process for both versions is the same. Without further ado, let’s get started.

First, you’ll need to install Google Analytics by MonsterInsights plugin.

If you haven’t installed this plugin yet, follow our step by step guide on how to install MonsterInsights plugin below:

Log in to your WordPress dashboard.

Click “Plugins” and select “Add New”.

Find the plugin by typing the name “MonsterInsights” in the search box.

Google Analytics by MonsterInsights” will appear in the top results for the keyword search,

Click “Install Now” and activate it.

After you’ve activated the plugin, you’ll see a new menu item “Insights” on your sidebar menu.

Next, click Insights > Settings.

To connect Google Analytics with your WordPress, you’ll need to click “Authenticate with your Google account”.

By doing this, Google will be able to collect information about your site visitors.

You’ll be directed to a Google login page where you’ll be asked to sign in to your Google account.

Log in to your Google account and click “Next” to continue.

To give permission for MonsterInsights to access your Google Analytics account, you’ll need to click “Allow”.

In this final step, you’ll need to select the profile/ website you want to track.

Once you’ve selected your website, click “Complete authentication”.

That’s it! You’ve successfully set up and installed Google Analytics on your WordPress site.

It will take some time before Google Analytics start showing your stats.

The most amazing aspect of MonsterInsights is that you can view your analytics report Inside your WordPress dashboard.

On your sidebar, click “Insights” >“Report” to have a quick overview of your analytics data.

Under the Tracking tab, you can customize a few additional tracking settings according to your needs.

The default settings for “Ignore these user roles from tracking” is administrator and editor.

This means that whenever WordPress user with the role of administrator or editor log into the website, they will ignore you as a visitor and will not send data to Google Analytics.

How to Install Google Analytics Using Insert Headers & Footers Plugin

For method 2, we’re going to use Insert Headers and Footers plugin.

It’s a simple plugin that allows you to insert code like Google Analytics to your WordPress site, without the need to edit your theme.

Compared to MonsterInsights, you can’t see your Google Analytics report in your WordPress dashboard and you won’t be able to do any advanced tracking.

But it’s a very useful plugin if you just want to add your Google Analytics to your WordPress site,

To get started, you’ll need to install and active Insert Headers and Footers plugin.

If you haven’t installed this plugin yet, follow our step by step guide on how to install Insert Headers and Footers plugin below:

Log in to your WordPress dashboard.

Click “Plugins” and select “Add New”.

Find the plugin by typing the name “Insert Headers and Footers” in the search box.

Insert Headers and Footers” will appear in the top results for the keyword search,

Click “Install Now” and activate it.

Once the plugin is activated, go to “Settings” and click “Insert Headers and Footer”.

Now you’ll need to copy and paste the Google Analytics code given in step 2 into the headers box.

Remember to click “Save”. That’s. You’re all set.

How to Install Google Analytics in WordPress Theme

This method is for advanced users who are familiar with the code.

It is somewhat unreliable because your code will disappear if you switch or update the theme.

We almost never recommend using this method.

If this is your first time adding code to your WordPress files, then you should check out a guide on how to copy-paste code snippets in WordPress.

Add code in header.php file

Simply edit the header.php file in your WordPress theme and paste the code you copied in step 4 right after the <body> tag.

Don’t forget to save your changes and upload the file back to your server.

Add via Functions File

You can also add Google Analytics tracking code to the WordPress functions file.

It will then automatically add the tracking code to every page on your WordPress site.

You will need to add this code to your theme’s functions.php file.

add_action('wp_head', 'wpb_add_googleanalytics');
function wpb_add_googleanalytics() { ?>
// Paste your Google Analytics code
<?php } ?>

Google Analytics Reports

Google Analytics will show you important data collected from your web stats. You can view this in-depth analysis in your Google Analytics dashboard.

Under the reporting tab, you can see that there are few options:

  • Real-Time shows you how many visitors are on your blog and the pages they are reading now.
  • Audience reports will help you understand your visitors.
  • Acquisition reports show you where your visitors are coming from.
  • Behavior reports let you track the performance of your content and evaluate the actions of your visitors.
  • Conversions reports summarize your performance against your goals.


Google Analytics is a must-have tool in managing your WordPress blog. It will help you understand what your audience wants from you and thus improve your site’s performance.

It will help you understand what your audience wants from you and thus improve your site’s performance.

Do you have any problem or question following this tutorial to set up Google Analytics on your WordPress site? Feel free to comment below.

I’ll be sharing more of ideas and guides soon. Stay tuned.

Written by Vishal Rana

Founder and Editor-in-Chief of 'PresentBlogging'. Grey Hat Hacker, Cyber Security Consultant, Information Security Researcher, Programmer, Developer, Social Engineer, Penetration Tester, Professional Blogger and SEO expert.


Leave a Reply

Your email address will not be published. Required fields are marked *





Plugins For A New Wordpress Blog

15 Must-Have Plugins For A New WordPress Blog/ Website

What To Do When You Don't Feel Like Writing

What To Do When You Don’t Feel Like Writing?