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. Paul Maddock says:

    You might want to add in at the end of this article the use of the ‘Real Time’ -> ‘Overview’ report. You can immediately see if you’ve installed the tracking code correctly if you’re getting any data at all showing in GA.

    I just followed this awesome guide and was able to see myself on the site, which was pretty satisfying :)

  2. Nick Darlington says:

    Hey, thanks this was a great help.

    At the end, after you have pasted the code, mention going back to step 4 and clicking save?

    Perhaps im being stupid, but theres no save button anywhere.

  3. Drew says:

    Great easy to use tutorial. Thank You!

  4. Jayson Schlesinger says:

    Thank you for such a simple and easy video, not a tech expert and this video made it effortless.

  5. Josh Rachlis says:

    Great, thanks. I’m working on launching my new self-hosted WordPress site. I just added the Insert Headers and Footers Plugin, like you suggested, and I pasted the code into Footers. So, we’ll see if it works! Do you happen to know if adding Stat Counter would help as well? I used to love looking at Stat Counter for my older blog, because it showed who was visiting and what they Googled to get to me. But, Google is hiding that info now, right? So, is there no point in having Stat Counter as well? Do you know of any work around trick to see that kind of info?

    • WPBeginner Support says:

      Josh. Many users find statcounter easier to understand than Google Analytics. There is no harm in using them both on your site.

  6. Sherluck says:

    Hi, I installed Google analytics plugin yesterday. It does not show any data from 30 days. Does it just start tracking from the day I installed it? how can I track the last years data? Thanks

    • larry says:

      Hi Sherluck,
      Yes, it only starts tracking once you install Google analytics. It has no historical data.

  7. E.S. Michelson says:

    Good post. Thank you.

    Near as I can determine Google Analytics will not work on a account unless you upgrade to, or have, a WordPress business plan. ($299/yr.)

  8. Bill says:

    Thank you for the tip. I downloaded a Header/footer plugin and it worked great.

  9. moko says:

    Uh wow! great article.. i need this .. thanks

  10. Maris says:

    How to hide tracking code from page source?
    Everyone can see it….

  11. Maya Mey Aroyo says:

    First I wanna say that I really love this website, been using it quite a lot lately..
    I already have a google analytics account on a different website (actually 2), and I can’t seem to find how to add my two new sites to that account…
    I tried the help on the analytics itself, and got to the page where I can add a URL- but the fill-in boxes where grey and I had no option filling in the details. Any advice?


  12. Febriyan Lukito says:

    I want to ask about the analytics plugin itself. I use the one from Yoast. Is it recommended to install such plugin? Please help on this.

    • WPBeginner Support says:

      If you find it hard to add Analytics code to your website, then you can use such plugins.

  13. Tony McBride says:

    Easy to follow and I liked the fact that you had the video as well as text to explain the how to.
    My site is set up now for tracking, thank you!


  14. Ahmad Tahir says:

    I a£ using wordpress blog from that doesn’t allow for plugin installation. I don’t know how to access the websites files on the server.

  15. Mieke Fassart says:

    I had a perfectly running report until April third. After that date my traffic is zero. Can you help?

  16. ROnald says:

    With a multisite network of independent blogs that I administer: Do I need to install Google Analytics *before* I convert the clean WP install to a multisite network, or *after* it has been networked. I want Analytics to report on each site independently.

  17. elizabethsusanjoseph says:

    I followed all this information. but I am getting an error message as follows:

    “Tracking code on page does not match property example sites tracking ID UA-61……”

    What might be the problem.

  18. Mahe Karim says:

    I paste this code on my function.php bt not working so i again remove analytical code but my site still showing that “Parse error: syntax error, unexpected ‘<' in /home/eishkool/public_html/~/wp-content/themes/wpstart/functions.php on line 452"

  19. Dawn Reber says:

    This was a very simple and easy to follow tutorial for setting up google analytics. Thanks!

  20. j says:

    great thanks a lot, i love you guys. however google says all too briefly:

    “Create a PHP file named “analyticstracking.php” with the code above and include it on each PHP template page.”

    google provides this google tracking code to use:


    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),



    ga(‘create’, ‘YOURTRACKINGCODEHERE’, ‘auto’);

    ga(‘send’, ‘pageview’);

    most of us will know that is the analytics tracking snippet

    so i put this in a plain txt file and save as .php fairly simple, but is this the right syntax for a php file? im new and i dont think so – but its what google said to do?. also

    including it on each php template page.. can this just be done with the php get_analyticstracking.php include tag? and if so does my analyticstracking.php script belong in my theme folder or the includes folder?

    the aim here is to call this tracking script into each template file using the include and then adding the following line to each template page immediately after the opening tag:
    to track each page where it is implemented.

    i like the idea of having the tracking done in the php rather than the open headers or footers but im not about to risk breaking the site to do this method when i dont fully understand it. am i on the right track?

  21. Janie Nafsinger says:

    I see the analytics code across the top of my screen above my header even though I pasted it into my footer as instructed?

  22. amanda says:

    Nowhere (except here, on the bottom of all the instructions) does it tell you that a WordPress blog (not self-owned) cannot use Google Analytics! Just want a good stats tracker that will show the visitors to my (free) WordPress blog. I have a StatsCounter counter but it doesn’t show the landing pages or exit pages. It does for my site, but it stopped doing it for my WordPress blog a few months ago. Entirely. I took down the code and re-entered it, even signed up to another tracker and it just won’t communicate right with WordPress and I can’t get that info! Help, anyone?

  23. Lisa Moore says:

    Google specifically says to insert the tracking code before the tag (article here Why are you telling readers to insert the code after the tag instead?

    • Steve says:

      You are so right Lisa although it does work if in footer. The problem I’m having is when I try to verify the analytics in Webmasters Tools, it declines stating it cannot find tracking in HEAD! So I will be going back and putting in Head and not Footer.

  24. WPBeginner Staff says:

    Give it at least 24 hours before your data may start showing up in your analytics account.

  25. Jackie says:

    I had an Analytics account just “there,” but I didn’t use it. Now I want to start using it, and it has the correct information, but it’s showing no activities on my blog. I’ve even installed it onto my WordPress dashboard and it’s still not showing activity.

    Any thoughts??

  26. Deb Lara says:

    Pasted the PHP code snippet along with my GA script in the functions.php file and it worked well. Was looking for the best way to escape using a plug-in! Thanks for this! :)

  27. Concerned Citizen says:

    You refer to “Step 6″ a couple times but I cannot find a “Step 6″.

    • WPBeginner Staff says:

      Thank you for notifying us, we have updated the article. This is an old article rewritten several times since then to keep up with changes. The step 6 is actually step 4 now. Hope this helps.

  28. Lumia says:

    Yes you can

  29. Lumia says:

    Ask those who set up the page and installed analytics to grant you access…

  30. Nathan Pierce says:

    I got a website from someone else. It already has Google Analytics installed. I assume that the Google Analytics account is connected to his Google account, so I won’t be able to transfer that to my own Google account. (It’s impossible to transfer YouTube videos from one Google account to another.)

    So if I set up my own Google Analytics account, and hook that up to the website, will I loose historical data?

    Would this procedure differ from the above?

  31. mobilepundits says:

    I am using online WordPress blog and i want to create Google analytics in my blogs is their any solution please help me thanks!

  32. Linda says:

    I have moved my blog from a blogspot to a wordpress and i wonder if you know if i can change the adress in google analytics to the new one?

  33. WPBeginner Staff says:

    paste the code in header.

    • eh mon! says:

      your video says footer

    • Lucie says:

      I have the same problem. It is really so easy, just to copy the UA code into header? And Do I lost all my historical data on my blog ? I would be so grateful for some help :)

  34. 2wanderers says:

    I am trying to set up Google Analytics with the Plugins Method (Recommended). Where do I paste the code: in the header or in the footer. Could anyone who has tried tell me whether it has worked for them?

    Many thanks

  35. susana says:


    I want to paste the code by using the plugin Insert and Footer. Where do I paste into the header, footer or both in the plugin settings?

  36. Amanda says:

    For the plug-in option, do you paste the code into the header or footer box in the settings?

  37. Rukkie says:

    Please how do I know it’s working after installing the tracking code in the plugin?

  38. WPBeginner Staff says:

    Yes this is the tag.

  39. Zomi Daily says:

    There is no tag in the header.php file of twenty fourteen theme, the only tag similar is <body >

    So where should we place the code?

  40. DreamKatari says:

    Thanks for this. Its so great

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.