簡體   English   中英

Google Analytics(分析)自定義變量腳本不起作用

[英]Google Analytics Custom Variable Script not working

我的網站上有以下腳本,用於將自定義變量推送到Google Analytics(分析)。 但是即使在5天后,該數據也不會出現在分析中。 有人可以注意到我在這里做錯了什么嗎?

<!-- BEGIN GOOGLE ANALYTICS CODE -->
<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(['_setAccount', 'xxxxxxxxxx']);
    _gaq.push(['_trackPageview']);

    _gaq.push(['_setCustomVar', 1, 'Product SKU','Test Data', 3]);
        //]]>

</script>
<!-- END GOOGLE ANALYTICS CODE -->  

附加信息:此腳本來自Magento的Google Analytis模塊,我正在GA.php中編寫_toHTML方法

實際設置自定義變量的行位於_trackPageview()調用之后,因此,自定義變量實際上不會發送到Analytics服務器。 設置自定義變量后,您需要添加_trackPageview()或_trackEvent()調用。

_gaq.push(['_setAccount', 'xxxxxxxxxx']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setCustomVar', 1, 'Product SKU','Test Data', 3]);
_gaq.push(['_trackEvent', 'Tow Truck', 'go', '-', 0, true]);

以下是一些與此有關的其他參考資料: http : //www.lunametrics.com/blog/2011/12/30/google-analytics-custom-variables-working/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM