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

发布于 2024-10-31 05:52:25 字数 1147 浏览 1 评论 0 原文

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

我启用了 Onepage checkout - 它执行一些 ajax 操作,基本上以手风琴格式加载 6 个不同的步骤。我想用 Google Analytics 跟踪每一步,这样我就知道是什么让用户望而却步。我找到了这个链接(http://magentoexpert.co.uk/2009/03/08/tracking-one-page-checkout-abandonment-with-google-analytics-properly/)通过 Google 执行此操作分析 - 但它使用旧的 GA 代码。我正在使用使用 gaq 推送的异步代码。

这是他们推荐使用的代码。

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

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

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

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

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

我需要 catch(err) 吗?完整的代码是什么 - 这似乎对我不起作用?

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

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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

触ぅ动初心 2024-11-07 05:52:25

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

浅忆流年 2024-11-07 05:52:25

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

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

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

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

暮年慕年 2024-11-07 05:52:25

这是我正在运行的代码,请注意底部添加的功能。我想跟踪失败的提交按钮操作,这被添加到 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>

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:

<!-- 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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文