2012-05-04 2 views
3

Googleアナリティクスのトラッカーを自分のopaアプリケーションに追加したいと考えています。私は私のHTMLコードの閉鎖の直前にGoogleによって提供されるスクリプトを置く必要があります。opa:google analytics

どうすればいいですか?

答えて

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:あなたはスクリプト内{をエスケープしなければならないことに注意してください:\{