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. https://developers.google.com/analytics/devguides/collection/analyticsjs/events).

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!

Advertisements

Sr. Software Engineer

Tagged with: , , , , ,
Posted in Shopify

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Recent Posts
%d bloggers like this: