3

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

我怎样才能做到这一点 ?

4

1 回答 1

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>

注意:请注意,您必须{在脚本内转义:\{

于 2012-05-04T22:33:06.033 回答