How To Add Google Analytics Code In WordPress (Step by Step)

Add Google Analytics Code In WordPress
  • Save

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 million views a day, you need to have a stats program which helps you to track blog traffic and analyze them.

In my earlier post, I have shared about three stats program for WordPress blog, and Google Analytics is one of the free stats programs that is must have for any blog. I would not get into details of the 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

Let’s start the guide with setting up a 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 log in 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 has an account, click on Admin tab at the top > select account and click on add a new property.

Google analytics new property
  • Save

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

  • Save

Click on Get Tracking ID and you will find your Google Analytics tracking code or script.

  • Save

Depending upon the method we are using to put Google analytics code to WordPress, we may be using only tracking ID or the complete script. Basically, this is what will help us connect WordPress with Google analytics for tracking site visitors and more.

The next step is to put Google Analytics code in WordPress

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

1. Google tag manager:

  • Save

I started using Google tag manager in 2013 and it becomes 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 set up and once you are done, you don’t have to worry about tag management in the future.

Here is a 5 minute tutorial on integrating GTM on your WordPress blog.

2. Using your WordPress theme:

WordPress Theme Footer code
  • Save

Many of you might not beware of the fact that most of the WordPress theme has an option to add header and footer script. You can use this to add GA tracking code to your WordPress site.

Simply copy the tracking code which you obtained in the step 1, and go to theme setting option, look for the option to add footer script and paste the code.

It will work seamlessly, and moreover, you don’t have to rely on another plugin for the simple task. The above screenshot is from popular Genesis theme framework.

3. Using Google Analytics for WordPress plugin

  • Save

There are many Google analytics WordPress plugins available in plugin repo. Some of them are free and some are paid.

Google Analytics plugin by Monsterinsights is the most popular one.

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.

  • Save

Click on save settings, and you have successfully configured the plugin. If you want to see Google Analytics data in your dashboard Click on Insights > Dashboard

  • Save

Of all the three options, I recommend Google tag manager option as it will make your life easier in the longer run.

If you are an experienced blogger & need more data like which category is the most popular.

Which authors are driving most page views then I suggest you use MonsterInsights plugin.

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 LinkedIn.

Subscribe on YouTube

Add Google Analytics Code In WordPress
  • Save
Authored By
A Blogger, Author and a speaker! Harsh Agrawal is recognized as a leader in digital marketing and FinTech space. Fountainhead of ShoutMeLoud, and a Speaker at ASW, Hero Mindmine, Inorbit, IBM, India blockchain summit. Also, an award-winning blogger.

18 thoughts on “How To Add Google Analytics Code In WordPress (Step by Step)”

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

  2. 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.

  3. Saurabh Patil

    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.

  4. 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.

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

  6. sangeetha menon

    Harsh,

    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 ?

  7. Swapnadip Chakraborty

    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

  8. The DarkKnighT

    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 🙂

  9. 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

  10. i have one question. after install the plugin where i see the traffic status google analytic or wordpress dashboard. thanks

  11. @Harsh,

    A debt of gratitude is in order for sharing this data. There is a decent module for WordPress called “Google Analyticator” yet you let us know another thing about Google logical code. I will attempt it in my web journal.

    Regards,
    Sneha Meena

  12. Hello Sir, I have an doubt.. can I use same google analytic code for my website and my youtube account..

    Thank You

  13. Hello…! Interesting & informative post.I will follow your tips for analyzing my site in future. You have providing a great help to me through this guide.

    Thanks a lot

  14. Thanks! This was extremely helpful. I didn’t know getting analytics was this important before reading this article

Leave a Comment

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

Scroll to Top
61 Shares
[i]
[i]
[i]
[i]
Share via
Copy link