![](/img/trans.png)
[英]Integrating Google Tag Manager with gatsby-plugin-guess-js
[英]Is this the correct way to use Google Tag Manager for Gatsby
我最初只是添加了Gatsby谷歌標簽管理器插件,並將GTM-XXXX添加到了我的配置中。 但是我的SEO負責人說,他希望此代碼包含在
<!-- Google Tag Manager (noscript) --> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <!-- End Google Tag Manager (noscript) -->
所以我將默認的html.js像這樣復制到src中: $ cp .cache/default-html.js src/html.js
,然后將該jsx放置在html.js中
<body {...this.props.bodyAttributes}> {this.props.preBodyComponents} <div key={`body`} id="___gatsby" dangerouslySetInnerHTML={{ __html: this.props.body }} /> {/* Google Tag Manager (noscript) */} <noscript> <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXX" height="0" width="0" style={{ display: 'none', visibility: 'hidden' }} /> </noscript> {/* End Google Tag Manager (noscript) */} {this.props.postBodyComponents} </body>
我的SEO家伙告訴我這樣做正確嗎? 為什么Google Tag Gatsby插件不能單獨使用?
這是noscript標記,僅對不運行Javascript的人顯示。 由於Gatsby是一個Javascript框架,沒有Javascript的人將看不到您的網站,所以我有根據的猜測是,該插件的開發人員認為沒有必要包含noscript標記(也是在沒有Javascript的GTM中起作用的唯一標記/事件是自定義圖片標簽上的頁面加載,因此擁有它們通常沒有多大意義。
我不知道這與SEO有什么關系。 我認為您不需要這個。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.