SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    Community Advisor ULTiMATE's Avatar
    Join Date
    Aug 2003
    Location
    Bristol, United Kingdom
    Posts
    2,158
    Mentioned
    45 Post(s)
    Tagged
    0 Thread(s)

    WordPress and Google Analytics

    This is an issue that hundreds seem to be having, and getting an answer other than "put the code after the </body> tag in footer.php" is near impossible at the official WordPress forums. Has anyone here had any issues with getting Google Analytics to work with WordPress? I'm using the ga.js code rather than legacy urchin code.

  2. #2
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I have never had any trouble!

    Though I gotta ask, why can you not just do as they say at the WP support forums and place it right after the </body> tag in the footer.php file in your active themes folder?

  3. #3
    Community Advisor ULTiMATE's Avatar
    Join Date
    Aug 2003
    Location
    Bristol, United Kingdom
    Posts
    2,158
    Mentioned
    45 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BPartch View Post
    I have never had any trouble!

    Though I gotta ask, why can you not just do as they say at the WP support forums and place it right after the </body> tag in the footer.php file in your active themes folder?
    I don't know. For some reason Google never seems to find the code there and continuously tells you in the main Analytics page that you need to change your tracking code. From what I can gather after looking at the WordPress forums it's a pretty big issue.

  4. #4
    whagwan? silver trophybronze trophy akritic's Avatar
    Join Date
    Nov 2006
    Posts
    2,780
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    The ga.js code doesn't play well with WP for some reason, though I did not investigate why exactly.

    I put the code before the closing </body> tag, but after the <?php wp_footer(); ?> code, and that seemed to work ok for me.

    Are you using the new version of WP?

  5. #5
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Google Analytics works fine with WordPress. Whatever problems you are having are unrelated to the software.

    As long as it is in your theme, it should work. If not, you are doing something wrong (or Google is).

    What is the URL to your site? It isn't possible to bug fix this type of thing without seeing the code first hand.

  6. #6
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After my flippant comment above about it being impossible that WordPress is causing the problem, I thought I'd better actually double check I wasn't missing some obvious cause of this problem.

    So I had a rifle through the WordPress support forums looking for info. about problems people are having with Google Analytics, but I couldn't find anything suggesting that there is a problem with WordPress and Google Analytics at all.

    Could you point me in the direction of some?

    Most of the comments I saw were from people misunderstanding how to edit their themes, plus the occasional one who I suspect was getting confused by their theme not having a footer.php file (not all themes do).

  7. #7
    SitePoint Member
    Join Date
    Apr 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're using WordPress.org, self hosted. Delete all the code you've added. Download this plugin.

    http://wordpress.org/extend/plugins/...for-wordpress/

    Upload it to your plugins folder, activate it, at the top of the plugins page you should now see Google Analytics Click the link. Where it says Analytics User Account you need to put your analytics code in.

    It will look something like this: UA-5743920-5 Once done, head down to update settings click it and away you go. You just have to wait for Google to pick up your tracking code.

  8. #8
    Community Advisor ULTiMATE's Avatar
    Join Date
    Aug 2003
    Location
    Bristol, United Kingdom
    Posts
    2,158
    Mentioned
    45 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ryanhellyer View Post
    After my flippant comment above about it being impossible that WordPress is causing the problem, I thought I'd better actually double check I wasn't missing some obvious cause of this problem.

    So I had a rifle through the WordPress support forums looking for info. about problems people are having with Google Analytics, but I couldn't find anything suggesting that there is a problem with WordPress and Google Analytics at all.

    Could you point me in the direction of some?

    Most of the comments I saw were from people misunderstanding how to edit their themes, plus the occasional one who I suspect was getting confused by their theme not having a footer.php file (not all themes do).
    I done my search through Wordpress.org's forums, and here are the results from searching 'analytics' on there. As you can see there are a lot of people having the same issues as me.

    http://wordpress.org/search/analytics?forums=1

    Quote Originally Posted by Funked View Post
    If you're using WordPress.org, self hosted. Delete all the code you've added. Download this plugin.

    http://wordpress.org/extend/plugins/...for-wordpress/

    Upload it to your plugins folder, activate it, at the top of the plugins page you should now see Google Analytics Click the link. Where it says Analytics User Account you need to put your analytics code in.

    It will look something like this: UA-5743920-5 Once done, head down to update settings click it and away you go. You just have to wait for Google to pick up your tracking code.
    I really didn't want to have to use a Plugin to get it to work. Simply put, it should just work if the code is on the page, so there's either some mystical way of getting it to work or the plugin will be draining resources somewhere. Either way last time it didn't work using the Plugin either, so I'll give it a try and see how things go.

    I'm using a modified version of the original theme, so there shouldn't be any problems.

  9. #9
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ULTiMATE View Post
    I done my search through Wordpress.org's forums, and here are the results from searching 'analytics' on there. As you can see there are a lot of people having the same issues as me.

    http://wordpress.org/search/analytics?forums=1
    I had a look at the link, but don't see anything to suggest there is a problem with using Google Analytics with WordPress.

    Whatever problem you are having is not related to WordPress. The software you use is unrelated to how Analytics works, it is just a simple external Javascript. As long as the analytics code is on your page (in the correct position) and isn't being interfered with by other code on your page, then it should function as expected.

  10. #10
    Community Advisor ULTiMATE's Avatar
    Join Date
    Aug 2003
    Location
    Bristol, United Kingdom
    Posts
    2,158
    Mentioned
    45 Post(s)
    Tagged
    0 Thread(s)
    Really? Here's a few.

    http://wordpress.org/support/topic/165133
    http://wordpress.org/support/topic/157648
    http://wordpress.org/support/topic/124380
    http://wordpress.org/support/topic/124002
    http://wordpress.org/support/topic/126087

    What I gather is that for some reason this code isn't working for a few people. Also, I cannot see how this could possibly be messing up, considering on the sub-domain I have my Blog installed on there is nothing but WordPress.

    Google knows the code is there, but for some reason it cannot receive the data, so something must be stopping it.

  11. #11
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I saw some of those links already. None of those posters provided enough information to figure out what their problem is. It is impossible to help figure what the problem is without a link to the site in question. Many (all) of them seemed very confused about how to edit their theme too which doesn't help.

    This person claimed to have fixed their problem, but never gave a link or explained what the problem was.

    Quote Originally Posted by ULTiMATE View Post
    Didn't provide a link so we could check.

    Quote Originally Posted by ULTiMATE View Post
    Couldn't even find their body tag intitially.

    Quote Originally Posted by ULTiMATE View Post
    Also seemed confused about where their body tag was.

    Quote Originally Posted by ULTiMATE View Post
    Claims it doesn't work, but doesn't even explain WHAT isn't working. Is it appearing in their HTML? Is Google not detecting it?


    So no, none of those links suggest that there is a problem with using Google Analytics with WordPress. It doesn't make any logical sense for it to be a problem. If it is in the theme and your theme doesn't have conflicting Javascripts then it will work ... unless Google is having issues.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •