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

Comments

  1. Sarah says:

    Thank you for these really easy instructions. I think I’ve cracked it (took a little bit of playing around to figure out how to use the plugin). Now fingers crossed I should get the information that I’m after.

  2. Hamza waqar says:

    In your plugin setting we’ve to insert code in footer or header or in both ?

    Please answer this ASAP. I’m stuck

    • WPBeginner Support says:

      In one of them. Pasting a code in both will make the code appear twice on every page of your site.

  3. Tommy G says:

    Hi there,

    I am trying to install my google analytics tracking code to my website via word press, and I am having a hard time getting the “insert headers and footers” plugin to install properly. I keep getting “Unable to create directory”. Anybody have any fixes to this?

    • WPBeginner Support says:

      It seems that an earlier plugin install attempt ended prematurely. Go to Plugins > Installed Plugins screen and see if you have insert headers and footers there.If it is there then try activating it. Or you can connect to your website using an FTP client and go to wp-content/plugins and delete the insert-headers-and-footers directory. Try to reinstall plugin after that.

  4. Pam Wilson says:

    These instructions no longer work. When I sign into my google account using your link it takes me to a Security settings page. When I just searched for Google Analyltics, there are several options. I assume “standard” is the one you recommend, but there’s no nifty walk through like you lay out in your article. After searching, I found this link to get me to where you sent us (I think)

    • WPBeginner Support says:

      The instructions work perfectly. Actually Google may change signup page URL. All you need to do is to visit Google Analytics website and then click on the Signup button.

  5. Liesl says:

    You might have already answered this but I am sick and the brain is not at 100% functioning capacity.

    1) Now that I have pasted the code into my footer via settings, does that cover very page and blog on my site?

    2) What is the benefit of pasting the code into the header as well as the footer?

    3) When I installed your plug in it warned that it may not be compatible with the latest version of wordpress 4.2.2 And I noticed that you haven’t upgraded this version in over a year. Will it still be compatible with all of the changes?

    Regards………Liesl

  6. Chris says:

    I’m running WordPress 4.2.2 on by blog and it says that the Insert Header and Footer plugin has not been tested on this version. Will it still work? Any other suggestions?

    Thanks.

  7. 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 :)

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

  9. Drew says:

    Great easy to use tutorial. Thank You!

  10. Jayson Schlesinger says:

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

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

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

  13. E.S. Michelson says:

    Good post. Thank you.

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

  14. Bill says:

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

  15. moko says:

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

  16. Maris says:

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

  17. Maya Mey Aroyo says:

    Hey,
    First I wanna say that I really love this website, been using it quite a lot lately..
    Second,
    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?

    Cheers!

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

  19. 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!

    Tony

  20. Ahmad Tahir says:

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

  21. Mieke Fassart says:

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

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

  23. elizabethsusanjoseph says:

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

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

    What might be the problem.

  24. 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"

  25. Dawn Reber says:

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

  26. 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:

    (function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){

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

    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)

    })(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);

    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?

  27. 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?

  28. 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?

  29. Lisa Moore says:

    Google specifically says to insert the tracking code before the tag (article here https://support.google.com/analytics/answer/1008080?rd=1). 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.

  30. WPBeginner Staff says:

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

  31. 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??

  32. 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! :)

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

  34. Lumia says:

    Yes you can

  35. Lumia says:

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

  36. 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?

  37. 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!

  38. 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?

  39. 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 :)

  40. 2wanderers says:

    Hi,
    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
    Susana.

  41. susana says:

    Hi,

    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?

  42. Amanda says:

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

  43. Rukkie says:

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

  44. WPBeginner Staff says:

    Yes this is the tag.

  45. 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?

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