WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Google Analytics for WordPress] Version 2.7 - 2 bugs to report (3 posts)

  1. scormeny
    Member
    Posted 5 years ago #

    My apologies -- I posted this at the end of the thread in another discussion about this plugin, but because it is marked "resolved" I wanted to create a new "unresolved" topic so that Joost de Valk will hopefully be alerted to its creation.

    I've noted in version 2.7 that the code is coming up before the body tag, not after it. The documentation at Google says it needs to be AFTER the body tag. Any plans to address this?

    Also, I noticed that on my blog, which is in WordPress 2.6.3, that the spot on the plugin administration page where you can change the location from footer to header, presents the wrong question -- it says "Track full URL of outbound clicks or just the domain?", which is the incorrect question to be asking, of course.

    Thanks for an otherwise reasonably smart plugin that I'm happy to have installed!

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

  2. Joost de Valk
    Member
    Posted 5 years ago #

    Hi scormeny, thx for pointing it out.

    In regards to the script position: the latest version actually supports adding the script to the header. Adding it right behind the body tag, as you would like to do, is, I'm sorry to say, kind of impossible at the moment. To explain why you'll have to allow me to explain a small bit about plugin internals.

    Plugins "attach" to certain "hooks". A hook is a call in the theme that says "ok we're here now, everything that has attached to this hook can now do what it has too". These come in two forms: actions, and filters. Actions allow you to directly output content, filters allow plugin authors to change a specific piece of content.

    There are two hooks that are obligatory in each theme: wp_head, which allows plugin authors to output code in the header, and wp_footer, which, you've guessed it, allows them to output code in the footer. There is no hook called wp_body, although I'd love for WordPress to have that by default, which could do what you're asking.

    So there's two possible solutions: either accept this and put the code in the header (which will actually execute before the body load in 99.99% of the cases, thus working correctly), or dropping my plugin and adding the code on your own.

    Come to think of it, I might add another feature to the plugin, for advanced users, which would allow you to disable adding the code to the output, you'd have to do that yourself, but would do all the filtering to add tracking scripts to links etc.

    Regarding your second remark about the label not being correct: you're spot on, thanks. I'll fix that ASAP.

  3. scormeny
    Member
    Posted 5 years ago #

    thank you. too bad about the post-body-tag thing; hopefully in this brave new open-source-web-2.0 world, wordpress's developers and google's developers will start sharing information about these sorts of things and manage to create software like the GA javascript tracker, that works well right out of the box, for the two most awesome online services ever!

Topic Closed

This topic has been closed to new replies.

About this Topic