[英]Alternative google analytics tracking code?
I'm using the following code to add Google analytics to a website. 我正在使用以下代码将Google Analytics(分析)添加到网站。
The problem is... I don't have access to the source files, only an edit box in a (very old) custom CMS. 问题是...我无权访问源文件,只有(很旧的)自定义CMS中只有一个编辑框。
Pasting in <scripts>
works fine generally, but they have a templating solution in place which uses square brackets ( [
, ]
), and the GA code is messing it all up. 粘贴<scripts>
通常可以很好地工作,但是他们有一个使用方括号( [
, ]
)的模板解决方案,并且GA代码将其弄乱了。
I can think of 2 possible solutions: 我可以想到2种可能的解决方案:
My existing GA code 我现有的GA代码
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxx-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
能够在CMS外部托管文件,您可以将跟踪代码放在单独的文件中,并将其作为外部javascript包含在内。
You could try substituting in HTML entities 您可以尝试替换为HTML实体
[ = [
] = ]
so when they display in the browser they hopefully get interpreted correctly - I've seen that kind of approach work with this kind of issue in template languages before. 因此,当它们在浏览器中显示时,它们有望得到正确的解释-之前,我已经看到这种方法可以解决模板语言中的此类问题。
Failing that see http://perishablepress.com/3-ways-track-google-analytics/ - there's a few old school GA script option documented there. 如果失败,请参见http://perishablepress.com/3-ways-track-google-analytics/-那里记录了一些老式的GA脚本选项。 Cheers Ben 干杯本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.