opa:谷歌分析

时间:2012-05-04 15:40:34

标签: google-analytics opa

我想在我的opa应用程序中添加谷歌分析跟踪器。我需要在关闭html代码之前放置谷歌提供的脚本。

我该怎么做?

1 个答案:

答案 0 :(得分:1)

您可以在主页末尾插入:

  <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>

N.B:请注意,您必须在脚本中转义{\{