How To Add Google Analytics To WordPress Blog

When I started blogging, stats of the blog was only for knowing how many visitors I’m getting, and with time I realize stats of my blog is the key to blog growth. It doesn’t matter if you have a blog with 100 views a day or a blog with 100 millions views a day, you need to have a stats program which help you to track blog traffic and analyse them. In my earlier post I have shared about 3 stats program for WordPress blog, and Google analytics is one of the free stats program that is must have for any blog. I would not get into details of benefits of Google analytics, as I have already covered it here. In this tutorial, you be learning about setting up your Google analytics account and adding Google analytics into your WordPress blog.

I have simplified this guide to non-technical users too, so you don’t have to worry about tech-how of Google analytics & WordPress integration.

How to Setup Google Analytics Account

Lets start the guide with setting up Google analytics account for your WordPress blog. You can repeat the same process for any website too. If you are doing this for your first website, you need to go to Google analytics page and login using your Google account or create an account which is free. For the first time setup, you will be asked to add your website details and your personal details to get started. If you are someone who already have an account, click on admin tab at the top > select account and click on add new property.

Google analytics new property

On the next page you need to add your website details to get the tracking code. Here is a sample screenshot from one website:

Setting up Google Analytics

Click on Get tracking ID and you will be moved to the page with tracking ID for your website.

Google Analytics Tracking ID

So far you have successfully setup your Google analytics account and created the tracking ID for your website. Now the most interesting part of this tutorial begins; as you need to integrate Google analytics tracking ID into your WordPress blog. Let’s have a look at it into next section.

3 ways to add Google Analytics to WordPress

There are multiple ways to add Google analytics (GA) into your blog, and depending upon your level of blogging you should pick one of the below mentioned methods. I’m putting down the different methods based on my recommended methods

Option 1) Google tag manager:

I started using Google analytics in 2013 and it become my only tag manager for all my sites. It’s free and using it you can manage all the tags for your blog from one place. I recommend GTM to every professional and serious blogger. It hardly takes 5 minutes to setup and once you are done, you don’t have to worry about tag management in future. Here is a 5 minute tutorial on integrating GTM on your WordPress blog.

Option 2) Using your WordPress theme:

WordPress Theme Footer code

Many of you might not beware of the fact that most of the WordPress theme have an option to add header and footer script. You can use this to add GA tacking code into your blog. Simply copy the tracking code which you obtained in the step1, and go to theme setting option, look for option to add footer script and paste the code. It will work seamlessly and more over you don’t have to rely on another plugin for simple task. The above screenshot is from popular Genesis theme framework.

Option 3: Using Google Analytics for WordPress plugin

Google Analytics for WordPress

There are many plugins which are available in WordPress Plugin repo to add Google analytics to your WordPress blog, but Google Analytics plugin by Yoast is the best. All you need to do is to install GA for WordPress plugin from official repo (plugin link) and configure it, which I have explained below. Once you have activated the plugin, you will see a popup asking to allow or disallow tracking, which I prefer to select “Do not allow tracking”.

Go to settings > Google analytics to configure the plugin and click on click here to authenticate with Google or you can also select manually enter the UA code.

analytic account

Click on save settings and you have successfully configured the plugin. You can also check this official guide by Yoast to configure other options of the plugin. If you want to see Google analytics data in your dashboard, Analytify is one useful plugin for you.

Of all the 3 options, I would recommend you to use the Google tag manager option as it will make your life easier in longer run. Here are essential GA tutorials for bloggers to move ahead in the series:

Do let me know which method you are using to add Google analytics to your blog and what other stats program you are using to track visitors on your blog.  Don’t forget to share this tutorial with your friends on Google plus and Facebook.

Subscribe on Youtube

Article By
Harsh Agrawal is a blog scientist and a passionate blogger. He is blogging since 2008 & writes about Blogging, SEO, Make money online & tech. His blog, ShoutMeLoud receives 1 million Pageviews/month and have over 700K subscribers.


COMMENTs ( 10 )

  1. says

    Hi Harsh,

    I have a one question on these topic. Hope u will reply

    I have a website and a Blog . The Blog is in sub direcotry.

    Do we need to add same Analytics and Webmaster code as we are using for our website.

    Or Something else

  2. The DarkKnighT says

    Hey Harsh, really nice post. I am a newbie to this place called blogging. Just wanted to know if I can see the analytics data on my dashboard just with tag manager and analytify or do I need to install the analytics plugin as well?
    please reply asap :)

  3. Swapnadip Chakraborty says

    Hi Harsh,
    Thanks for this article. Google Analytics is the effective way by which we can easily get traffic information at our blog. You have mentioned to put tracking code in footer.php file of your theme . But I put my Google tacking code on header.php.

    So, I would like to know is there any problem if I put my blog tracking code before body tag of header.php?

    Thank you

  4. sangeetha menon says


    I have both Google analytics and jetpack for my wordpress self hosted blog. Though its for the same site, they show different stats for the same day . Which one to go for and why ?

  5. says

    Adding the analytics through the plugin is the best ways as you will never loose the code when you update the theme.

  6. Bobby Uppal says

    Dear Harsh,

    Thanks for sharing this information. There is a good plugin for WordPress called “Google Analyticator” but you told us a new thing about Google analytic code. I will try it in my blog.

  7. Saurabh Patil says

    Thanks Harsh!! The best method to integrate Analytics is via footer.php Edit Footer.php and place the code at the end so that the the script will load later after the content. Thanks for the post btw.

  8. says

    I am currently using Google Analytics plugin by Kevin Sylvestre and it is working perfectly in my website but here I found another great plugin therefore now I think I will change my plugin.

  9. Raplus says

    This is a really good guide for even non tech peoples. However, Histats also good alternative to Google Analytic.