How to implement google analytics event tracking in shopify?

How implement google analytics event tracking in shopify?
Hello Friends,
I hope you all are doing well.
I am here going to explains how to implement event tracking with analytics.js on your shopify website.
Generally we can implment google analytics event traking on our website in a easy way using jquery or js (Ref.
If you are going to implement event tracking code on your shopify websites then you can’t add event traking in a normal way. For add to event traking code on shopify website, you will must have need to follow shopify inbuilt function ShopifyAnalytics.merchantGoogleAnalytics()
You have need to call event traking within shopify analytics function.

window.ShopifyAnalytics.merchantGoogleAnalytics = function() {
// tracking code will be add here
ga(‘send’, ‘event’, [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
Example : Add event traking for newsletter
Find newsletter.liquid files (Admin >> Theme >> Edit code >> Section ) and add given below code under {% if form.posted_successfully? %} conditon

/* implement google event traking code */
window.ShopifyAnalytics.merchantGoogleAnalytics = function() {
ga(‘send’, ‘event’, ‘Subscribe’, ‘click’, ‘subscribeforcode’, 1);
If you found this post helpful then please don’t forget to like our facebook page.
Enjoy Code!

Leave a Reply

Your email address will not be published. Required fields are marked *