Issues with Google Tag Manager (GTM) Tracking in Shopify Theme Extension

Description:
Hello everyone,

I have developed an app along with a corresponding theme extension for Shopify. My goal is to track user events such as viewing time and click events for analytics purposes.

What I’ve Tried:
I’ve attempted a straightforward approach by appending the GTM snippets using JavaScript in my theme extension. The GTM debug tools indicate that events are being received and that the tags are firing correctly. However, I cannot see the tracked data in Google Analytics 4 (GA4).

Additionally, I tested the GTM implementation on other websites, where it worked as expected. However, the tracking does not seem to function properly when integrated with Shopify.

Questions:

  1. I noticed that Shopify offers a Web Pixel feature. Would it be more effective for me to use Web Pixel instead of injecting GTM directly into my online store?
  2. If I should continue using GTM, how can I properly configure it to ensure that it captures data in GA4?
  3. Are there any specific Shopify rules or restrictions that might be affecting GTM’s functionality? Or could it simply be a configuration oversight on my part?

Any guidance or insights would be greatly appreciated. Thank you!

For best practice you can create an App Pixel with your app to use Web pixel events for better Customer event tracking. Though you should consider also adding GTM events as Theme extension for further tracking, such a Page view or any other custom event.

You can find more information in the following link:
https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/gtm-tutorial

The Web Pixel will run in a Sandbox, so there’re some limitations to consider:
https://help.shopify.com/en/manual/promoting-marketing/pixels/overview#pixels-sandbox-limitations

Hope this is helpful.

Enrique

If you are trying to create GTM in an app to only track on the storefront, I would recommend the theme app extension. You’ll need to consider privacy to ensure you respect the merchant customer privacy settings.

For web pixel in an app you need to build an app pixel extension. This runs in a web worker and you wouldn’t be able to get GTM to work. However, you can run GTM in a custom web pixel.

1 Like

@enrique_ya you can add a GTM events though checkout with Web Pixels. Depending on what info you want/need could limit you depending on where you are trying to send tracking to. What are you trying to send within GTM and to where?