2016-07-05 5 views
0

GoogleアナリティクスとShopify用に設定された電子商取引トラッキングよりも優れたトラッキングを構築しようとしています。ShopifyのGoogleアナリティクスイベントトラッキングコードに問題がありますか?

私のフロントページには、ベストセラーのリストがあります。これらの製品はカートに追加できますが、これはajaxで行われ、製品が追加されるとカートにリダイレクトされません。 Googleアナリティクスの目標イベントを使用してこのイベントをトラッキングしようとしました。以下は、カートのフォームに追加製品です:あなたが見ることができるように

<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アナリティクスの目標に追加されます。

しかし、これをテストすると、リアルタイムビューには表示されないため、動作しません。

アイデア?

答えて

2

_gaq方法は、あなたはおそらく、analytics.jsのためにこのような何か新しい構文を必要とするga.jshttps://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApi_gaq

にレガシー呼び出しです:私はこのコードを使用してこれを固定 ga("send",{hitType:"event",eventCategory:"click",eventAction:"bestseller",eventLabel:product.title}) https://developers.google.com/analytics/devguides/collection/analyticsjs/events#overview

+0

いいえ。それは動作しません。 私はこれを 'onClick = 'ga(' send '、' event '、' bestsellers '、' click '、' {{product.title}} '、' {{product.price | money_without_currency}} ' ); " –

0

を:

onClick="ga('send', 'event', 'Bestsellers', 'Added to Cart', '{{ product.title }}', '{{ product.price | money_without_currency }}');" 
関連する問題