简体   繁体   English

将 Google 跟踪代码管理器 (gtm) 安装到 Angular 应用程序

[英]Install Google Tag Manager (gtm) to Angular app

I tried to install GTM to an Angular app by adding the script to the head and the iframe to the body in the index.html file.我尝试通过将脚本添加到头部并将iframe添加到index.html文件中的正文来将GTM安装到Angular应用程序。

I load the app in Chrome an I can see that are added in the html.我在 Chrome 中加载了该应用程序,我可以看到它已添加到 html 中。

The Google Tag Assistant plugin from Chrome detects it well but when I go to the Network tab I can't see any gtm.js request and also I type in the console google_tag_manager and I get google_tag_manager is not defined . Chrome 中的Google Tag Assistant插件可以很好地检测到它,但是当我将 go 转到 Network 选项卡时,我看不到任何gtm.js请求,并且我在控制台中输入 google_tag_manager并且我得到google_tag_manager is not defined

I tried the plugin angular-google-tag-manager but happens the same.我尝试了插件angular-google-tag-manager但发生了同样的情况。

I don't know what's going on, any guess?不知道怎么回事,猜猜看?

I found what was going on.我发现发生了什么事。

I had an script for the cookies of my app and I guess is using gtm or analytics and commenting that script solved the problem.我有一个我的应用程序的cookies脚本,我猜是使用gtm分析评论脚本解决了这个问题。 I also tried changing the order of the scripts and also solved the problem, first my gtm script and after the cookies script which was causing the problem.我还尝试更改脚本的顺序并解决了问题,首先是我的 gtm 脚本,然后是导致问题的 cookies 脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM