Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides


  1. Laura says:

    Hi friends!

    I have a question about thi topic. Where is better add my analytics code?


    and why?

    Thank you!

  2. Kuda Makurumure says:

    Thanks for this; very much appreciated. Used the recommended Plugins method; it’s straight forward, no issues, no fuss, works right first time

  3. Gianfranco D AGOSTINO says:

    Hello, i am still using my localhost/mysite as the URL of my WP site. when i am trying to register that information on the Google Analytics page, it doesn’t let me register. do i need to first put my WP on a server and register a domain name, so after that can i start using Google Analytics? Thank you very much and excuse me for my english!.

  4. Missy says:

    Please where exactly do i paste it? The header or the footer?

  5. Sapna says:

    I’ve signed up and have a Google Analytics code, but am still setting up my WordPress site and creating content; my site just has a Coming Soon page I created through a plugin. Should I wait until I launch my site to paste the Google Analytics code into Yoast/the theme’s code? Does it affect anything if I do this pre-launch?



  6. Taciana says:


    I am using Monster Insights at my website.
    Once I done all settings, I no longer need to insert Google Analytics code in every page at my website?
    The plugin tracks all my pages?
    It is the same ideia for WordPress Yoast for Google Console?


  7. Katherine says:

    Hi, is there a way to tell the difference between ‘real people’ and ‘spambots’ in the analytics dashboard? I’m using the Monster Insights plugin but am pretty sure that the numbers are extremely high given I have a small local business… I’d be very surprised if the numbers I’m seeing are real people…

  8. Amy says:

    Thank you for the tutorial – very helpful!!!

    I have installed my code in a footer in the site, but I also have the Google Analytics by Monster Insights dashboard added as well – is this doubling up? I can’t really tell as I haven’t really launched the site yet, I am just in the beginning stages of getting all of the backend work completed before I truly “go live.”

    Thank you again for your insights!

  9. Jamie says:

    A good tutorial, though Analytics now tracks whenever I use the WP Admin pages as well. Any idea on how to solve that?

  10. J says:

    To be honest, I find it unnecessary as WordPress itself has already very good analytics and data tracking. But good tutorial.

  11. Andrew Carter says:

    Extremely useful tutorial. Thank you very much indeed.


  12. Himanshu Sharma says:

    Hello there
    I need some help here. What to do if i had already signed up for the analytics but forgot to copy that code. How do i get the code now ?

    • Mariuselix says:

      You can find the tracking code in your Google Analytics account -> Admin tab -> Property (select the site from the dropdown list) -> expand Tracking info -> click Tracking code

  13. Fabian says:

    top, thanks !! easy and helpful, quick & efficient ! to the point !

    • Anish Ponnala says:

      Login to your analytics account.Then click on admin(it is located on the left side at the top).
      Then select the website and then click on tracking info.

  14. Philip Verghese Ariel says:

    Hi WP team,
    This is an informative tuto well explained.
    How nice it would have been if I read this few years back,
    I am sure this will be a great help to the newbie bloggers.
    Keep sharing such informative and educational pieces.
    May you have a profitable day.
    Philip Ariel

  15. Ekta says:

    Hi, i tried to follow your instruction. I activated the plugin insert headers and footers and then went to settings.
    The header and footer are blank. I just have pasted the code from Google analytics and saved. Is that correct?
    I am not sure about this ”paste it in your theme’s header.php right after the tag”.

  16. guntaka subba Reddy says:

    How is add google analytics blog like if we are running a ecommmerce site and maintaining blog . Two different versins . please letme know

  17. Emma C says:

    Super helpful tutorial – thank you!

  18. Marie says:

    Thank you very much for this super simple tutorial! Very helpful :)

  19. Tania says:

    Very helpful! I just don’t know, after I click ‘save’, where can I see the stats. Cause I click it and nothing happens.

    • WPBeginner Support says:

      You will need to login to your Google Analytics account. It may take upto 48 hours for Google Analytics to start showing stats.

  20. Mert says:

    Copy and paste to my theme’s header.php right after the tag will enable me to track every post and page? Or just the home page? If it is just the homepage, then how I can add this code to my every single page? Btw I do not like using plugins, since It reduces loading speed of website.

  21. Amber says:

    Thanks very much! I’ve been staring at this for days >.< I'm so glad its up and running so I can see how few people I'm getting to my site ;P

  22. pk says:

    where we have to add this plugin…in header or in footer..
    pl clarify this . it is little bit confusing.

  23. Cameron Archibald says:

    I would like to point out that the direct paste method states to put the code right after the tag. I would recommend putting it right before the tag. As it is Google’s recommendation and is required if you want to verify Search Console through GA method.

    I think if Google recommends it you should do it right?

    • Cameron Archibald says:

      Sorry the code was cut out…It states right after the body tag but it should go right BEFORE the closing head tag.

      • Jonathan Beltran says:

        I believe you are correct. With the Google Tag Extension for chrome enabled, it flags that it the GA tag should be included within the tag. View this link for reference:

        • Jonathan Beltran says:

          I’m sorry, it cut off. I meant that the GA script should be placed within the head tag.

  24. Nancy says:

    Can google analytics be added to a blog with free plan on wordpress??

  25. Leo Stalin says:

    Awesome explanation, thanks.

  26. Jone Quest says:

    When I click the Add new account option nothing happen. Any ideas?

  27. Melissa Merriam says:

    Thanks for the refresher.

  28. Gianni Contestabile says:

    As usual, this was a great help! Thank you very much for the detailed info and video.


  29. LIsa says:

    Very helpful but yes, there is a bit of confusion between the written and the video ~ I added to both the header and footer box with the reasoning being that I can easily go back and edit if necessary. Thanks for all the help!

  30. Marcus says:

    Great help ..

  31. Luke says:

    What amazing explanation..
    Thank you very much for your time and effort invested in this video…

  32. Fernanda says:

    This was great help! Thank you very much for the detailed info :)

  33. Milan says:

    The video helped a lot! It was the easiest tutorial I came across and actually worked!

    Thank you so much!

  34. Rachel says:

    Just followed the video found it very easy to use. Thank you

  35. Bjorn says:

    Thanks a lot for the helpful tutorial!

  36. Pravin Nath.K says:

    Hey buddies, Install Google analytics using Yoast analytics plugin is best choice. If you are switch theme, the code will be on your blog forever.

  37. Andy Simpson says:

    Personally I’d use Google Tag Manager and then add GA

  38. Mina says:

    I used the plugins method. It was superb and easy as well! Thanks WPbeginner for your great tutorial.

  39. Amy Hunt says:

    I copied the PHP code straight into wordpress and it crashed my whole site, I had to go into my host files and delete it.

    Apparently I wasn’t supposed to use the PHP at the start or end of the code along with the // at the end but why was it included??

  40. Florence says:

    The video shows her putting the code in the footer, but the written material says to put it in the header. Thought I would point this out. It is very confusing. The video shows script in both header and footer, but no instructions to do both.

  41. saijad says:

    i followed second method for adding Google Analytics in my blog.

  42. Bud Johnson says:

    I have installed google analytics on my computer and have also installed google analytics dashboard for wp. I have carefully gone through all of the steps in the tutorial and obtained an access code. When I paste this access code into the feed and save it I keep getting an error message. It says I don’t have a valid account. Any suggestions?

  43. David Catlin says:

    I initially installed “Header and Footer” instead of “Insert Headers and Footers”–very confusing! It took me a while to figure out why what I was seeing on my site didn’t quite match the video, which was frustrating. I think I have it straightened out now.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.