Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
I need a hand. In the Empire theme of my Shopify store, I need to put corresponding tracking codes:
//when a product is viewed in store gtag('event', 'view_item', { 'send_to': ‘…..’, 'value': ….., 'items': [{ 'id': ‘…….’, 'google_business_vertical': ‘…….’ }] }); //when a product is added to cart gtag('event', 'add_to_cart', { 'send_to': ‘…..’, 'value': ….., 'items': [{ 'id': ‘…….’, 'google_business_vertical': ‘…….’ }] }); //when a product is purchased gtag('event', 'purchase', { 'send_to': ‘…..’, 'value': ….., 'items': [{ 'id': ‘…….’, 'google_business_vertical': ‘…….’ }] });
Can someone please, share step-by-step instructions how and where to put these codes exactly, in order to make them do the right thing?
Also, should I call any other script in section, and which?
What additional things I need to do?
Where can I read more about these and similar things?
My store theme is Empire theme. The upper codes need to be placed in the theme itself. Where exactly in the theme I need to put those codes to do trackings when a product is viewed in store, when a product is added to cart and when a product is purchased, as stated just above each piece of script.
Please, be as precise as you can.
Thank you a lot!
I think you want to add custom events to google analytics.
Paste this code in product's liquid Page
//when a product is viewed in store gtag('event', 'view_item', { 'send_to': ‘…..’, 'value': ….., 'items': [{ 'id': ‘…….’, 'google_business_vertical': ‘…….’ }] });
same way add to cart should fire on the button click event
//when a product is added to cart gtag('event', 'add_to_cart', { 'send_to': ‘…..’, 'value': ….., 'items': [{ 'id': ‘…….’, 'google_business_vertical': ‘…….’ }] });
This should be placed in an additional script area.
//when a product is purchased gtag('event', 'purchase', { 'send_to': ‘…..’, 'value': ….., 'items': [{ 'id': ‘…….’, 'google_business_vertical': ‘…….’ }] });
Hope you are familiar with the code files.If not let me know.I can help you out.
User | RANK |
---|---|
8 | |
4 | |
4 | |
3 | |
2 |