Javascript Shopify中的Google Analytics事件跟踪代码问题?
试图建立一个比谷歌分析和Shopify建立的电子商务跟踪更好的跟踪 在我的首页上,我有一张畅销书的清单。这些产品可以添加到购物车中,但这是通过ajax完成的,一旦添加了产品,就不会重定向到购物车。我尝试使用Google Analytics目标事件跟踪此事件。以下是将产品添加到购物车表单:Javascript Shopify中的Google Analytics事件跟踪代码问题?,javascript,google-analytics,shopify,Javascript,Google Analytics,Shopify,试图建立一个比谷歌分析和Shopify建立的电子商务跟踪更好的跟踪 在我的首页上,我有一张畅销书的清单。这些产品可以添加到购物车中,但这是通过ajax完成的,一旦添加了产品,就不会重定向到购物车。我尝试使用Google Analytics目标事件跟踪此事件。以下是将产品添加到购物车表单: <form method="post" action="/cart/add"> <input type="hidden" name="id" value="{{ produ
<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,它也添加到了谷歌分析目标中
但是,当我测试它时,它不会出现在实时视图中,因此它不起作用
有什么想法吗?gaq方法是对
ga.js
您可能需要analytics.js
的新语法,如下所示:
ga(“发送”{hitType:“事件”,eventCategory:“点击”,eventAction:“畅销书”,eventLabel:product.title})
u gaq方法是对
ga.js的传统调用
您可能需要analytics.js
的新语法,如下所示:
ga(“发送”{hitType:“事件”,eventCategory:“点击”,eventAction:“畅销书”,eventLabel:product.title})
我使用以下代码修复了此问题:
onClick="ga('send', 'event', 'Bestsellers', 'Added to Cart', '{{ product.title }}', '{{ product.price | money_without_currency }}');"
我使用以下代码修复了此问题:
onClick="ga('send', 'event', 'Bestsellers', 'Added to Cart', '{{ product.title }}', '{{ product.price | money_without_currency }}');"
不。那不行。我也尝试了这个
onClick=“ga('send'、'event'、'bestsellers'、'click'、'{{product.title}}'、'{{product.price | money(无_currency}}}}')”
Nope。那不行。我也尝试过这个onClick=“ga('send'、'event'、'bestsellers'、'click'、'{{product.title}}'、'{{product.price | money(无_currency}}}');”