商品がカートに追加された後、商品ページに次のコードがあります。
<script type="text/javascript>
//<![CDATA[
(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';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
var _gaq = _gaq || [];
_gaq.push(['_setCustomVar', 1, 'Page Type', 'Product', 3])
_gaq.push(['_setCustomVar', 2, 'Product Name', 'Gold Bracelet', 3]);
_gaq.push(['_trackEvent', 'Product Page', 'Added To Basket', 'Gold Bracelet', , 0]); // this is the line that isn't working.
_gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
_gaq.push(['_trackPageview']);
//]]>
</script>
ページビュー、2 つのカスタム変数は追跡されているようですが、_trackEvent は追跡されていません。タイトルで述べたように、このコードをコピーして Chrome Dev Console に貼り付けると、イベントは問題なく表示されます。_trackPageview を返すコードに alert() を追加したところ、うまく機能したため、JS は確実に解析されています。
私が間違っていることは何ですか?
ありがとうございました