0

如何在 Typo3 网站上添加 Google Tag Manager 代码?

我尝试安装唯一可用的 Google 跟踪代码管理器扩展,但它破坏了我的安装。(幸运的是,我在此处的一些帮助下修复了它)

现在我正在寻找在typo3模板页面或类似的东西中添加代码。目标是代码必须在该网站的所有页面上可见。

(我对 Typo3 完全陌生,所以一步一步的指南会很棒)

4

2 回答 2

3

So I've found the answer to my question. I thought it would take me much longer because configuring TYPO3 is a bit cryptic for a newbie like me.

step 1. open the TYPO3 admin interface
step 2: in "Template" open the root template and choose to edit the "Setup" part. A sort of text editor will open.
step 3: Somewhere in that text you have to add this

page.headerData.999 = TEXT
page.headerData.999.value(
# add your tracking code here
)

Make sure to exchange the line "# add your tracking code here" with your tracking code. I have added this code just below the [global] tag in that config file.
step 4: Hit the save button. Now your tracking code should show up on all pages of your TYPO3 installation.

Additionally it's also easy to add the noscript tag (as mentioned in Google Tag Manager's quickstart guide immediately after the opening <body> tag:

page.1 = TEXT
page.1.value (
    # add your noscript-tracking code here
)
于 2013-10-21T08:22:46.097 回答
1

今天面临同样的问题。我们不想使用扩展,所以我们使用了下面的方法。

Google建议将标签管理器放在开始标签之后。从您的代码看来,您正在将标签添加到页面中。

要将其添加到页面正文,请使用“###MARKERNAME###”转到主模板文件和市场。

例如

<div id="container" class="home">
   <div id="google-tagmanager">
     ###TAGMAN###
  </div> 

然后转到模板 > 模板 > 主页模板 (PAGE) > 设置。将标记及其注入值添加到页面对象

# GOOGLE TAG MANAGER     
marks.TAGMAN = TEXT    
marks.TAGMAN =< lib.gtmContainer

最后,将 lib.gtmContainer 添加到您的Standard Page Parts (LIB)中。

lib.gtmContainer = TEXT
lib.gtmContainer.value (

  <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXX" height="0"              width="0" style="display:none;visibility:hidden"></iframe></noscript>  
  <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
 '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
  })(window,document,'script','dataLayer','GTM-XXXXX');</script>
  )

这似乎对我们很有效。希望能帮助到你!

于 2014-04-29T15:16:19.647 回答