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!

Related posts

  1. Updated my Google Analytics plugin to track AdSense clicks
  2. Google Analytics: Adding search engines in the new version
  3. Using segmentation in Google Analytics for WordPress RSS readers
  4. Google Analytics plugin updated!
  5. Google Analytics for WordPress: my latest plugin

Want more WordPress tips?

You should subscribe to my WordPress Newsletter, as you'll get a whole lot more WordPress tips and tricks there! Also, subscribe to this blog right now with RSS, or daily or weekly emails!

32 Comments to “WordPress Google Analytics 2.3: XHTML strict”

  1. Martey

    Martey Jan 2nd, 2008 at 19:38

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

    tirm Jan 5th, 2008 at 11:03

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

  3. gus

    gus Jan 6th, 2008 at 17:09

    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 Valk

    Joost de Valk Jan 6th, 2008 at 22:24 Delicious Digg StumbleUpon Twitter

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

    gantico Jan 7th, 2008 at 10:50

    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 Valk

    Joost de Valk Jan 7th, 2008 at 10:52 Delicious Digg StumbleUpon Twitter

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

  7. gantico

    gantico Jan 7th, 2008 at 11:08

    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:
    http://www.gantico.com/blog/2007/12/wordpress-plugins/

    Happy New 2008!

  8. tirm

    tirm Jan 7th, 2008 at 11:15

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

  9. Joost de Valk

    Joost de Valk Jan 7th, 2008 at 11:33 Delicious Digg StumbleUpon Twitter

    You're so right tirm... Thx for noticing! 2.4.1 fixes that :)

  10. tirm

    tirm Jan 7th, 2008 at 20:49

    where I can download 2.4.1? :)

  11. Joost de Valk

    Joost de Valk Jan 7th, 2008 at 20:51 Delicious Digg StumbleUpon Twitter

    here, as always.

  12. tirm

  13. Austin

    Austin Jan 12th, 2008 at 21:46

    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.

    http://www.wheneverday.com

  14. Austin

    Austin Jan 12th, 2008 at 21:53

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

    pat Jan 13th, 2008 at 04:55

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

    pat Jan 13th, 2008 at 05:02

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

    ph Jan 13th, 2008 at 23:55

    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. John Morris

    John Morris Jan 14th, 2008 at 01:10

    Great plug-in!! Thanks for your hard work!

  19. Joost de Valk

    Joost de Valk Jan 14th, 2008 at 01:13 Delicious Digg StumbleUpon Twitter

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

  20. Tracy Evans

    Tracy Evans Feb 11th, 2008 at 05:33

    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!

  21. Joost de Valk

    Joost de Valk Feb 11th, 2008 at 20:17 Delicious Digg StumbleUpon Twitter

    @Tracy: no it won't.

  22. bob

    bob Apr 24th, 2008 at 03:34

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

  23. Scott Johnson

    Scott Johnson May 3rd, 2008 at 06:27

    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.

  24. Scott Johnson

    Scott Johnson May 3rd, 2008 at 06:32

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

  25. Scott Johnson

    Scott Johnson May 3rd, 2008 at 07:20

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

  26. Richard

    Richard May 28th, 2008 at 03:49

    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.

  27. Joost de Valk

    Joost de Valk May 28th, 2008 at 06:10 Delicious Digg StumbleUpon Twitter

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

  28. Richard

    Richard May 28th, 2008 at 15:33

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

  29. Jon

    Jon Jun 12th, 2008 at 11:14

    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

    Jon

  30. newbie

    newbie Sep 30th, 2008 at 23:13

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

    Thanks.

  31. Vincent

    Vincent Oct 15th, 2008 at 14:11

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

    cheers

  32. Crazy2

    Crazy2 Nov 1st, 2008 at 13:40

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

Leave a Reply

Joost de Valk a.k.a. Yoast Want an avatar too?
Go to gravatar.com and upload your preferred avatar.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

SEO Book Tools
BLVD Status
SearchEngineWatch
Directory Journal
Pepperjam
Free Google Traffic
Hosting by:
Hosted by MediaTemple Grid Services