我想在我的opa应用程序中为google analytics添加一个跟踪器。我需要把google提供的脚本放在我的html代码结束之前。
我该怎么做呢?
发布于 2012-05-05 06:33:06
您可以在主页的末尾插入:
<script>{
Xhtml.of_string_unsafe("
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-Y']);
_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>注意:注意,您必须在脚本中转义{:\{
https://stackoverflow.com/questions/10451975
复制相似问题