How to run GTM on strapi?

I’ve been trying to integrate GTM on my strapi app via Measurement Protocol | Strapi Market

but the document is super poor and lately I haven’t been able to do much progress

So far I’ve only done the config/plugins.js portion, but GTM isn’t being read anywhere on my application

This topic has been created from a Discord post (1234592468322750534) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Any updates here? it’s been 2 weeks

Hey can you confirm if you’re wanting to have tracking on Strapi itself (the admin panel) or your user application?

I would like to have traction on the user application (when clicking buttons, switching pages etc)

In which case this is nothing to do with Strapi. Whatever your front end is you need to implement Google analytics or some other tracking platforms. Instructions would depend on the platform you choose but this isn’t the place to find help with that specifically.

I think there’s a misunderstandment here - I do plan on implementing GTM on my Strapi application as a whole (when switching to different sites or when applying different plugins - my app is a website builder), however whenever I implement the GTM // GA4 tags, they are either not recognized or the events are not being read (and I’m boostraping dataLayer via app.js)

currently I’ve

  • implemented GTM // GA4 tags
  • whitelisted their respective noscript // script tags via middleware.js
  • created their own initialization setup by creating a plugin from scratch (pulling credentials via env/plugins.js) and then initializing their components via Initializer
  • added many events by calling the plugin service (that’s properly set up) around the application.

and currently

  • the GTM // GA4 tags are not being recognized by their respective Google debug tools
  • in a particular scenario, the google tags are being read but no events are being fired or even recognized at all
  • external libs are no helpful at all, I even tried manually editing react-ga4 lib code to adapt the setup but it was not helpful at all