我在body标记内的SharePoint母版页中添加了GTM代码。
<body>
<--Body content goes here -->
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXXXXX"
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-T9XLSX');</script>
<!-- End Google Tag Manager -->
</body>
但似乎脚本未正确触发,因为整个内容由表单元素包装如下。它由SharePoint生成。
<body>
<form method="post" action="" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">
<--Body content goes here -->
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXXXXX"
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-T9XLSX');</script>
<!-- End Google Tag Manager -->
</form>
</body>
我们是否可以在SharePoint中正确放置代码?
答案 0 :(得分:1)
有一种解决方法。您可以直接修改 SharePoint 2013中的“ .master ”页面使用 sharepoint designer , 在sharepoint表单的结束标记之后插入 GTM ,如下所示,
</SharePoint:SharePointForm>
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXXXXX"
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','sss');</script>
<!-- End Google Tag Manager -->
答案 1 :(得分:1)
我能够为SharePoint Online网站集解决它。假设打开了发布功能,我:
答案 2 :(得分:0)
您可以在codeplex中找到适用于此的沙箱解决方案。我保证这很好用。所有安装指南都在那里。