我使用望远镜为五月博客应用程序,我能够配置谷歌分析通过望远镜管理设置。现在我们想配置Google标记管理器,但是我们无法弄清楚如何用望远镜配置GTM。我们找到了一个"https://github.com/GorillaStack/meteor-iron-router-gtm“,它允许在流星中配置GTM,但它基于铁路由器,但使用流路由器进行望远镜。
有人能帮我们用望远镜配置GTM吗?
发布于 2016-03-13 06:51:33
这是我在项目中向client.js添加代码的工作。
if(Meteor.isClient){
FlowRouter.triggers.enter( [ enterFunction ] );
FlowRouter.triggers.exit( [ exitFunction ] );
function enterFunction() {
$('body').append("<noscript id='gtmnoscript'><iframe src=\"//www.googletagmanager.com/ns.html?id=GTM-XXXXXX\" height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\"></iframe></noscript><script id='gtmscript'>(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-XXXXXXX');</script>")
}
function exitFunction() {
$('#gtmnoscript').remove();
$('#gtmscript').remove();
}
}https://stackoverflow.com/questions/35824692
复制相似问题