【问题标题】:Google Analytics Event tracking code issue in Shopify?Shopify 中的 Google Analytics 事件跟踪代码问题?
【发布时间】:2016-11-07 20:04:46
【问题描述】:

尝试构建比为 Google Analytics 和 Shopify 设置的电子商务跟踪更好的跟踪。

在我的首页,我有一个畅销书列表。这些产品可以添加到购物车,但这是通过 ajax 完成的,一旦添加产品,您就不会被重定向到购物车。我尝试使用 Google Analytics 目标事件来跟踪此事件。以下是将产品添加到购物车表单:

<form method="post" action="/cart/add">
          <input type="hidden" name="id" value="{{ product.variants.first.id }}" />
          <input type="submit"  value="<ly-as-2156597>Add To Bag  |</ly-as-2156597>  {{ product.price | money }} " class="submit add hidden-phone"  onClick=”_gaq.push(['_trackEvent', 'bestseller', 'click', '{{ product.title }}', '{{ product.price | money_without_currency }}']);” />
        <a href="{{ product.url | within: collection }}"><input style="
    width: 60px !important;" type="button" value="<ly-as-2156598>View</ly-as-2156598>" class="submit" /></a>
        </form> 

如您所见,添加了 _trackEvent,它也添加到了 Google Analytics 目标中。

但是,当我对此进行测试时,它不会出现在实时视图中,因此无法正常工作。

有什么想法吗?

【问题讨论】:

    标签: javascript google-analytics shopify


    【解决方案1】:

    _gaq 方法是对 ga.js https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApi_gaq 的旧调用

    您可能需要analytics.js 的新语法,如下所示: ga("send",{hitType:"event",eventCategory:"click",eventAction:"bestseller",eventLabel:product.title}) https://developers.google.com/analytics/devguides/collection/analyticsjs/events#overview

    【讨论】:

    • 不。那是行不通的。我也试过这个onClick="ga('send', 'event', 'bestsellers', 'click', '{{ product.title }}', '{{ product.price | money_without_currency }}');"
    【解决方案2】:

    我使用以下代码解决了这个问题:

    onClick="ga('send', 'event', 'Bestsellers', 'Added to Cart', '{{ product.title }}', '{{ product.price | money_without_currency }}');"
    

    【讨论】:

      猜你喜欢
      • 2015-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-21
      • 2023-04-10
      相关资源
      最近更新 更多