Google Analytics Code

7 replies
Just added my website to google analytics a few days ago. I had been using 1&1 analytics before hand.

Ok so I have put the script from google analytics into my wordpress header.php where else do I have to put it to see the real number of visitors coming to my site? Any help appreciated. Thanks.
#analytics #code #google
  • Profile picture of the author adsense786
    There should be a footer.php . Look for the closing </body> tag there. Some themes use other file includes. If thats the case see which file is included at the end of footer.php .
    {{ DiscussionBoard.errors[4581041].message }}
    • Profile picture of the author Monumento
      So if I put the script into the footer.php that will show me the true traffic coming to my site? I will give this a shot but I must say I thought by just putting the script into my header.php it would track every visitor. I thought that the header.php was loaded for every page and post am I wrong here? :confused:
      {{ DiscussionBoard.errors[4581066].message }}
  • Profile picture of the author spacechimpmedia
    You only need to have Google Analytics in your footer just before the </body> or in the header before </head>. Whatever you do, do not put Google Analytics on your website twice. If you are a newbie with analytics just remove the hard coded version of analytics you put on the page and download the plugin "Google Analytics for Wordpress".
    {{ DiscussionBoard.errors[4581082].message }}
  • Profile picture of the author David Keith
    it does not matter about it being in the header or footer really. most just put it in the footer so their site loads first (which is more important)

    but as long as the code is in a file like header or footer that is on every page it will work.

    also note that google analytics is not a real time solution. it can 24-48 hours to show the initial stats after the first setup. and it will update about every 24 hours after that.
    {{ DiscussionBoard.errors[4581111].message }}
    • Profile picture of the author Monumento
      Ok so I have put the code in the right place in my header.php. I don't think google analytics is working correctly its saying I have 14 visitors a day! While 1&1 analytics is telling me I have about 200-400 visitors these last few days which I consider to be the true figure. Anyone else had problems with google analytic tracking?
      {{ DiscussionBoard.errors[4581153].message }}
  • Profile picture of the author Istvan Horvath
    Actually, the new analytics code in step 2 says this:
    Copy the following code, then paste it onto every page you want to track immediately before the closing </head> tag.
    Which means forget the footer (that was in earlier versions!) and do what it says.
    For a WP site, open the header.php, find the closing </head> tag and paste the code right before it.

    And to see the data regarding your visitors > login to your analytics account.

    {{ DiscussionBoard.errors[4581151].message }}
  • Profile picture of the author absolutelee
    GA seems to be pretty accurate for me. These are "real" visitors, not robots, by the way. That's might be part of the reason for the difference. Also, there's a time lag with GA of about a day. I would let it run for a few days before I made any decisions. Also, I would use the plugin mentioned above.
    {{ DiscussionBoard.errors[4581181].message }}

Trending Topics