最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why can't Google Tag Manager be installed within another HTML element under the body? - Stack Overflow

programmeradmin1浏览0评论

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?

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?
Share Improve this question edited Dec 30, 2013 at 7:08 Robert Kingston asked Dec 19, 2013 at 0:03 Robert KingstonRobert Kingston 3694 silver badges14 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 11

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./kb/927917 (archive)

http://blogs.msdn./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>).

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

Firstly to differentiate between the block and the block ponents 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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论