私は、VB.NET ですべて同じフレームワークである約 6 つの Web サイトを持つクライアントを持っています。それぞれに Google Analytics Tracker を追加しようとしましたが、成功しませんでした。WordPress Web サイトまたはカスタム CMS (JavaServer Faces 内) を使用している多くのクライアントが完全に機能しています。私はVB.NETで何か間違ったことをしていると確信していますが、これはほとんど使用していません。
現在使用しているVB.NETのコードは次のとおりです。
<head>
...
<!-- Google Analytics -->
<asp:ContentPlaceHolder ID="GoogleAnalyticsTracker" runat="server">
<script type="text/javascript">
alert('ga-start');
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<%= m_sIDGoogle %>']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_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);
alert('ga-stop');
}
)();
</script>
</asp:ContentPlaceHolder>
</head>
</body>
注: Google Analytics に記載されているように、私も直前に試しました。
レンダリングされた結果は次のとおりです。
<script type="text/javascript">
alert('ga-start');
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA–29119317–1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_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);
alert('ga-stop');
}
)();
</script>
また、2 つのアラート ('') が機能していることにも注意してください。Firebug から、ga.js も読み込まれていることがわかります。
結局のところ、Google アナリティクスでは何も追跡されません。誰かが私が間違っていることを知っていますか?
テスト Web サイトにアクセスすることもできます: http://mouk-mouk.amiesterre.com