如何使用Google Analytics Async跟踪Magento Onepage中的AJAX部分

时间:2021-11-13 14:47:49

I have a magento store and I am trying to track the progress of users at the checkout process.

我有一个magento商店,我试图在结帐过程中跟踪用户的进度。

I have the Onepage checkout enabled - which does some ajax stuff to essentially load 6 different steps in an accordion format. I would like to track each step with Google Analytics so i know whats putting the users off.. I found this link (http://magentoexpert.co.uk/2009/03/08/tracking-one-page-checkout-abandonment-with-google-analytics-properly/) to do so with Google Analytics - but it uses the old GA code. I am using the Async code which uses the gaq push.

我启用了Onepage结帐 - 这可以做一些ajax的东西,基本上以手风琴格式加载6个不同的步骤。我想跟踪谷歌分析的每一步,所以我知道什么是关闭用户..我发现这个链接(http://magentoexpert.co.uk/2009/03/08/tracking-one-page-checkout-abandonment - 谷歌分析 - 正确/)使用谷歌分析 - 但它使用旧的GA代码。我正在使用使用gaq push的Async代码。

So here is the code they recommend to use.

所以这是他们建议使用的代码。

 gotoSection: function(section)
    {
        try {
            pageTracker._trackPageview('/checkout/' + section + '/');
        } catch(err) {}

        section = $('opc-'+section);
        section.addClassName('allow');
        this.accordion.openSection(section);
    },

To update this to the Asynchronous version, would i use:

要将其更新为异步版本,我会使用:

 gotoSection: function(section)
    {
        try {
            _gaq.push(['_trackPageview', '/checkout/', + section + '/']);
        } catch(err) {}

        section = $('opc-'+section);
        section.addClassName('allow');
        this.accordion.openSection(section);
    },

Do i need the catch(err) ? What would be the full code - this doesn't seem to work for me?

我需要捕获(错误)吗?什么是完整的代码 - 这对我来说似乎不起作用?

3 个解决方案

#1


2  

I believe that the Fooman GoogleAnalyticsPlus extension on MagentoConnect will do what you need. YMMV.

我相信MagentoConnect上的Fooman GoogleAnalyticsPlus扩展将满足您的需求。因人而异。

#2


2  

For anyone who comes here, the above code does not work because it needs to be /checkout/onepage/ instead of just /checkout/

对于来到这里的任何人来说,上面的代码不起作用,因为它需要/ checkout / onepage /而不仅仅是/ checkout /

View correct example here: http://inchoo.net/ecommerce/magento/onepage-checkout-abandonment-google-analytics/

在此处查看正确的示例:http://inchoo.net/ecommerce/magento/onepage-checkout-abandonment-google-analytics/

#3


1  

This is the code I have functioning, note the added function at the bottom. I wanted to track failed submission button action, this is added to the onclick and generates its own independent event tracking adding the Submit Order step just previous to the success goal in the chain:

这是我运行的代码,请注意底部添加的功能。我想跟踪失败的提交按钮操作,将其添加到onclick并生成其自己的独立事件跟踪,在链中的成功目标之前添加提交订单步骤:

<!-- Google Funnel Stats -->
<script type="text/javascript">
Checkout.prototype.gotoSection = function(section) {

    try {
        // Google Analytics non-asynch code
        // pageTracker._trackPageview('/checkout/onepage/'+section+'/');

        // Google Analytics asynchronus code
        _gaq.push(['_trackPageview', '/checkout/onepage/'+section+'/']);

    } catch(err) { }

    section = $('opc-'+section);
    section.addClassName('allow');
    this.accordion.openSection(section);
}

function gaqSubmitOrder() {

    try {
        // Google Analytics non-asynch code
        // pageTracker._trackPageview('/checkout/onepage/'+section+'/');

        // Google Analytics asynchronus code
        _gaq.push(['_trackPageview', '/checkout/onepage/submitorder/']);

    } catch(err) { }

}
</script>

#1


2  

I believe that the Fooman GoogleAnalyticsPlus extension on MagentoConnect will do what you need. YMMV.

我相信MagentoConnect上的Fooman GoogleAnalyticsPlus扩展将满足您的需求。因人而异。

#2


2  

For anyone who comes here, the above code does not work because it needs to be /checkout/onepage/ instead of just /checkout/

对于来到这里的任何人来说,上面的代码不起作用,因为它需要/ checkout / onepage /而不仅仅是/ checkout /

View correct example here: http://inchoo.net/ecommerce/magento/onepage-checkout-abandonment-google-analytics/

在此处查看正确的示例:http://inchoo.net/ecommerce/magento/onepage-checkout-abandonment-google-analytics/

#3


1  

This is the code I have functioning, note the added function at the bottom. I wanted to track failed submission button action, this is added to the onclick and generates its own independent event tracking adding the Submit Order step just previous to the success goal in the chain:

这是我运行的代码,请注意底部添加的功能。我想跟踪失败的提交按钮操作,将其添加到onclick并生成其自己的独立事件跟踪,在链中的成功目标之前添加提交订单步骤:

<!-- Google Funnel Stats -->
<script type="text/javascript">
Checkout.prototype.gotoSection = function(section) {

    try {
        // Google Analytics non-asynch code
        // pageTracker._trackPageview('/checkout/onepage/'+section+'/');

        // Google Analytics asynchronus code
        _gaq.push(['_trackPageview', '/checkout/onepage/'+section+'/']);

    } catch(err) { }

    section = $('opc-'+section);
    section.addClassName('allow');
    this.accordion.openSection(section);
}

function gaqSubmitOrder() {

    try {
        // Google Analytics non-asynch code
        // pageTracker._trackPageview('/checkout/onepage/'+section+'/');

        // Google Analytics asynchronus code
        _gaq.push(['_trackPageview', '/checkout/onepage/submitorder/']);

    } catch(err) { }

}
</script>