• Resolved s6_mike

    (@s6_mike)


    Although this is an impressively full featured plugin, I can’t ignore the fact that it fails to follow Google’s installation guidelines.

    As stated here, the container and datalayer should appear immediately after the opening <body> tag:

    https://developers.google.com/tag-manager/quickstart

    This plugin inserts the container and datalayer towards the bottom of the body tag. This will stop it working correctly with tags that affect page elements appearing higher up on the page e.g. tracking forms using GA.

    I would love to use your plugin and recommend it to my clients, but this needs to be addressed first.

    Many thanks,

    Michael Hayes

    http://wordpress.org/plugins/duracelltomi-google-tag-manager/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi Mike,

    Thanks for your feedback!

    The placement of the container tag was a headache for me because WordPress has tools to insert it into the <head> element and at the bottom of the <body>.

    There is no way to insert anything after the starting <body> tag.

    What about a new option so that you can select the placement
    – head
    – body (bottom)
    – custom

    The “custom” selection would not place any code into the template but you could call a simple PHP function in your template to insert it properly after the opening <body> tag.

    BTW: most GTM tags are async, in my implementations there was nothing that did not work properly. That includes GA event tracking with forms, links, etc. Maybe if there is a specific issue, I could investigate it to get more details and overview.

    Thread Starter s6_mike

    (@s6_mike)

    Thanks for responding so quickly.

    That sounds like a great solution.

    Note that the plugin metronet tag manager’s solution is similar to your custom: you have to add a <?php do_action( ‘body_open’ ); ?> tag to the theme.

    Perhaps you could use the same function for consistency? Would make it easier for me to switch to yours 🙂

    I also saw a change request on WP’s code for a hook like this (while I was googling) which might be worth checking, but I don’t have the link handy.

    Thanks,

    Mike

    Thread Starter s6_mike

    (@s6_mike)

    Also if GTM appears in the head the <iframe> part of the code is meant to cause issues on IE so you might wish to warn your users of that.

    Plugin Author Thomas Geiger

    (@duracelltomi)

    I have two problems with this do_action() solution:
    #1 The name ‘body_open’ does not fit into the naming conventions of WordPress. ‘wp_bodyopen’ for example would be better imho.
    #2 Templates should include template tags and add_action() calls but no do_action() calls (imho)

    I already created the plugin to be able to make this step we are talking right now since there are two functions that can be called in your templates:
    gtm4wp_the_gtm_tag
    gtm4wp_get_the_gtm_tag

    They are working just the same way as other WP functions: the first outputs everything the second returns the code as a string.

    So basically the task for me is to create an option that prevents outputting the GTM script tag at the footer and lets you include a function call in your template files.

    For compatibility reasons I will include an action hook for ‘body_open’ as well but if you do not mind the preferred method to include the GTM tag after the opening body tag will be to call gtm4wp_the_gtm_tag()

    Thread Starter s6_mike

    (@s6_mike)

    Sounds good to me, thanks for taking so much trouble with your plugin.

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi Mike,

    I committed changes to the SVN repository into trunk.
    There is no release yet since I am working on other improvements.
    Until this you can check it out and try if you want.

    Please do not use it on production sites, try it only on development setups.

    Cheers,
    Thomas

    Hi duraceltomi,

    Based on your last conversation with Mike,

    “For compatibility reasons I will include an action hook for ‘body_open’ as well but if you do not mind the preferred method to include the GTM tag after the opening body tag will be to call gtm4wp_the_gtm_tag()”

    Does this mean that you have made the plugin to now be able to insert the GTM code right after the beginning of the Body tag? Or is it still in the Header?

    Thanks

    Plugin Author Thomas Geiger

    (@duracelltomi)

    The current developer version already includes an option that enables you to insert the GTM tag after the opening body tag (you have to insert one line of PHP code into you template).

    The current stable version includes it in the footer of the page.

    While starting the conversation with Mike I was having the plan to include an option to be able to insert the GTM tag into the head as well but finally I dropped the idea since it could cause malfunction in many cases.

    Release date for 0.4 is not set yet since my son is in hospital with my wife and I want to be with them as much as possible. Maybe this weekend or next week I will try to finalize code for 0.4 and do the release.

    Thanks for your reply.

    Sounds good. Will wait for 0.4.

    How & where do we insert the php code into template? I presume you’ll have instructions on that once it’s launched?

    Sorry to hear about your family. Yes spend more time with them. Hope they get well soon.

    Thanks

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    The extra code is needed to be inserted into the header.php of your template or where your openig body tag is implemented. I included the code on the admin page, you will find it quickly.

    Cheers,
    Thomas

    Hi duracalltomi,

    Thanks for this plugin, I installed and managed to get Analytics code working, but got errors using AdWords conversion tracking. I saw in my Tag Assistant that the code was not in the correct place.

    After reading the above comments I’m a little confused as to whether this is fixed or not.

    If there is extra code to be added, can you please leave instructions, either that or I’ll wait for a working version.

    Thanks, Kris

    Plugin Author Thomas Geiger

    (@duracelltomi)

    I am using the current stable version (0.3) on several websites and have no issues with AdWords tags. Although the GTM container tag is placed at the end of the <body> tag I did not see any problem with this so far.

    If the only message you get in the Tag Assistant is that the code is not placed correctly I would not worry, your AdWords conversion tracking should work as expected.

    The next version is going to include the option to place the GTM container tag to the proper place so yes, this has been fixed but the new version has not been released yet. It will be as soon as possible, hopefully in the coming days.

    Thank you for your patience.

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi all,

    The new version is out, would you be so kind and check it whether it fits your needs regarding code placement?

    Thanks,
    Thomas Geiger

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi all,

    Since there was no response to this topic since 1 week, I mark it as resolved.

    Thomas

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Container appears incorrectly towards bottom of body’ is closed to new replies.