WordPress Google Analytics 2.3: XHTML strict

After all the ASP and XHTML strict validation issues with Google Analytics, Google updated the default generated script code. I’ve now updated the Google Analytics for WordPress plugin to version 2.3, which uses this new code. You should really upgrade!

Next to that: I’d like to hear from you on which new features you’d like in this plugin, so if you have anything you want me to add, drop it in the comments!

Tags: ,

Yoast.com runs on the Genesis Framework

Genesis theme frameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides you with the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Read our Genesis review or get Genesis now!

32 Responses

  1. MarteyBy Martey on 2 January, 2008

    Version 2.3 still breaks XHTML validation on my website. When outbound link tracking is enabled, a footnote on my first entry (which is an internal link to a bookmark elsewhere on the page) causes strange things to happen to the onclick. Joost, I can email the source to you if you are interested.

    Also, the link tracking in my sidebar seems to be generating an extra ” at the end of the onclick attribute.

  2. tirmBy tirm on 5 January, 2008

    Function _trackVisit is incorrect Google messed up the documentation. You should change it to _trackPageview();

  3. gusBy gus on 6 January, 2008

    Great plugin, but a little unclear on this: We’ve got version 2.3 running, and (almost) every link now has onclick=”javascript:pageTracker._trackVisit(‘/outbound/typeoflink/nameoflink’);” after it. If I understand the comment above and one on the 2.2 announcement post correctly, this is wrong? Because Google Analytics is working, but not tracking outgoing links.

    I had understood this had been fixed in 2.3, but apparently not? If it hasn’t been, where in the code should I change _trackVisit to _trackPageview();? Or do we just need to wait for the next update for this to work?

    A second question: we’ve got a direct ad I’m trying to track clicks on, which is neither an article nor a blogroll link nor any of the other categories the plugin automatically sets up. How do I do it? Do I manually insert the onclick code into the anchor, or will that mess something up in the plugin? Or is there a class I can put on the link to put it into one of the categories that gets tracked? Or is there some way I can add “ads” as a new category for tracking?

  4. Joost de ValkBy Joost de Valk on 6 January, 2008

    Ok, please upgrade to 2.4, I’ve fixed both the trackPageview issue, which, gus, you were right on, and the XHTML is not broken anymore even with outbound link tracking on.

  5. ganticoBy gantico on 7 January, 2008

    Thanks for the update, I was wondering why it wasn’t notified by the plugins page in WP admin page. The other plugins usually tell you when an update is available.

  6. Joost de ValkBy Joost de Valk on 7 January, 2008

    That’s cached inside WordPress, so sometimes it takes a little while to update… It should work though.

  7. ganticoBy gantico on 7 January, 2008

    I forgot to say that I appreciated your great plugin: I donated 1$ and I added it to my top ten list of WordPress plug-ins:

    Happy New 2008!

  8. tirmBy tirm on 7 January, 2008

    hmm. I see _trackVisit in adsense-track.js
    googleanalytics.php realy fixed

  9. Joost de ValkBy Joost de Valk on 7 January, 2008

    You’re so right tirm… Thx for noticing! 2.4.1 fixes that :)

  10. tirmBy tirm on 7 January, 2008

    where I can download 2.4.1? :)

  11. Joost de ValkBy Joost de Valk on 7 January, 2008

    here, as always.

  12. tirmBy tirm on 7 January, 2008

    Thanks Joost

  13. AustinBy Austin on 12 January, 2008

    I LOVE the way you have put together this Analytics for WordPress plugin! I’m not a programmer, but it’s a really cool product and worth supporting. However, I just installed 2.4.1 and have tried over and over to “Check Status” from Google, and I still get “Tracking Unknown”. If it’s just me, then no big deal, but I thought I’d let you know because maybe something has changed in the last few days that messed with things. Thanks.


  14. AustinBy Austin on 12 January, 2008

    Wow, how ’bout a donation to the cause! I figured out that I hadn’t put in the full “http://” within Google Analytics. I hate being one of ‘those’ guys. :-)

    Thanks again!

  15. patBy pat on 13 January, 2008

    Hi, I’m having a bit of trouble installing this plugin – forgive me if I’m just being dumb, but I downloaded it and saved in my wp-content/plugins directory, but it does not appear in my wordpress plugins page

    Any help would be appreciated, thanks!

  16. patBy pat on 13 January, 2008

    Ok – I obviously jumped the gun a little bit. I now know that I just have to move the ‘gapp’ folder into wp-content/plugins. It might be a good idea IMO to change it so that you move the whole folder, as it makes installation a little easier/ slighty more standard.

    Thanks for the plugin!

  17. phBy ph on 13 January, 2008

    Anyone else having problems with outbound link tracking when the complete outbound URL is being tracked? I’m using 2.4.1 with WP 2.3.2. When I start drilling down in GA, I get to /content/articles, for instance, and then underneath there are just a couple of entries for /http:/ and /https:/ with nothing underneath them. Is there a problem with the URL parsing code?

  18. Joost de ValkBy Joost de Valk on 14 January, 2008

    @austin & pat: glad you both got it working :)

    @ph: that’s an issue indeed, I’ll make sure the next version removes all http:, https:// and www’s :)

    @john morris: my pleasure :)

  19. Tracy EvansBy Tracy Evans on 11 February, 2008

    Newbie question – If I start using this plugin (and delete the code I originally inserted into my pages to activate GA), will I loose the GA stats I have already gathered? Am I starting from scratch with my GA data? Thanks!

  20. Joost de ValkBy Joost de Valk on 11 February, 2008

    @Tracy: no it won’t.

  21. bobBy bob on 24 April, 2008

    Forgive me for asking, but why use the plugin when you can simply copy and paste the code Google provides you?

  22. Scott JohnsonBy Scott Johnson on 3 May, 2008

    It seems that the code for detecting the plugin path in this plugin is not bulletproof. You can see it in action on my site. With my WordPress setup, it’s causing a script src=”adsense-track.js”…no path to the script.

  23. Scott JohnsonBy Scott Johnson on 3 May, 2008

    I’m also seeing in another instance:
    script src=”/apps/wordpress/plugins/google-analytics-for-wordpress/custom_se.js”
    Where /apps/wordpress/plugins is where my global plugin repository is for that server. The actual plugin directory wp-content/plugins contains symlinks to the items in the plugin repository. In this case, /apps/wordpress is not accessible to the outside world directly. Users are getting 404s as a result. :(

  24. Scott JohnsonBy Scott Johnson on 3 May, 2008

    Joost, I’m just going to email you some recommended fixes. :)

  25. RichardBy Richard on 28 May, 2008

    Installed. Added url to google. Copied google code number to installation. logged out as Admin. Checked with google and found that it couldn’t verify the code on my home page. Checked the source of the home page and found the code in the header rather than near the tag. The adsense tracking code was there however. Have deactivated the plugin.

  26. Joost de ValkBy Joost de Valk on 28 May, 2008

    @Richard: the script installs itself in the header for some very good reasons, especially if you want to be able to track outbound clicks it sort of needs that.

  27. RichardBy Richard on 28 May, 2008

    Thanks Josh. I understand your reasoning but my research since having this problem shows me that installing in the header can delay the loading of web pages and is not advised by Google. At any rate google couldn’t find your code on my pages so slow or fast isn’t an issue. :)

  28. JonBy Jon on 12 June, 2008

    Thanks for a brilliant plugin Joost (and for all your articles on WordPress and SEO, they’ve really helped a ‘newbie’ get up to speed quickly)!

    A suggestion for an additional feature for the plugin – could you add an option to create the page that Google mentions in its help-tip on how to filter “internal users” from the statistics?

    See – https://www.google.com/support/googleanalytics/bin/answer.py?answer=55481&hl=en_US – the second option, “Exclude traffic by Cookie”

    Thanks again


  29. newbieBy newbie on 30 September, 2008

    Just wanted to find out if the Google script is placed in the header or footer. I also thought you would want to check out your speedtest: http://binarytendencies.com/tests/speedtest-2-google-analytics-plugins/.


  30. VincentBy Vincent on 15 October, 2008

    hi Joost,

    I was wondering if this plugin has advantages if you have Headspace2 installed. Headspace2 adds a lot of flexibility for meta tags, titles and so on. You have advised to use this also in your SEO WP optimisation page. In Headspace, I can also add my Google code.

    I am interested in the bonus to install this plugin together with Headspace, or worse if it would interfere? Is your plugin adding the analytics for downloads and outgoing links as a bonus? or this is in headspace too?

    Hope you can clear it up for me :)


  31. Crazy2By Crazy2 on 1 November, 2008

    With the 2.6.3 version and using outbond. i still doesnt get XHTML valdation.
    How can i fix?

  32. MaxBy Max on 19 March, 2009

    This question might sound a little stupid, since it appears that everyone understands what you are talking about… but no.. not me.. what is a “gapp” folder???