Question

The instructions for Google Tag Manager insists installing Google Tag Manager code immediately after the opening body tag. However, this is not always possible for some websites (without a ton of modification).

Trouble is, you can install Google Tag Manager elsewhere within a page and the tags appear to fire. However, if you check the installation with Google Tag Assistant, it fires a critical issue:

"Error: tag must not be included in a <div>"

When you click on the error message, you're directed to Google's lean documentation :

Google Tag Manager Tag should be placed immediately after the opening tag and not inside any other HTML element. The Google Tag Manager snippet must be placed directly in the page that you intend on tracking. Placing it in a hidden iframe or deploying it within another tag management system will prevent certain tags from accurately tracking the parent page. Tags added via Google Tag Manager may not fire. Please make sure to place the GTM snippet immediately after the opening tag.

  • Which sorts of tags won't fire?
  • Is it only for certain browsers?
  • Will it cause other issues?
Was it helpful?

Solution

This guideline is trying to help avoid some specific problems with using appendChild on unclosed ancestor elements in older versions of IE:

http://support.microsoft.com/kb/927917 (archive)

http://blogs.msdn.com/b/ie/archive/2008/04/23/what-happened-to-operation-aborted.aspx (archive)

You can avoid these problems by always placing your GTM snippet directly inside the body tag, not wrapped in any other elements (e.g. <div> or <td>).

OTHER TIPS

For practical purposes we need to dig deeper to have the instruction easier to implement.

Firstly to differentiate between the block and the block components in the GTM Snippet

For a particular client I'm seeing their IE 6 & 7 traffic to be insignificant and dropping. We therefore need not take those browser versions into account

Also their site is near impossible to use without JavaScript. For other clients, their GTM container may have no tags that will function without JavaScript.

In such cases it seems quite safe to dispense with the block and implement the bootstrap code in the .

While I've done this on occasion and got desired results, I will not claim to have tested it thoroughly.

We would benefit greatly from Brian or other GTM team members providing more in depth information on this problem

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top