Google Tag Manager?

Is there any recommended approach to set up the Google Tag Mnaager within the MainLayout cusotmlayout class? Or is there a better place to do it?

Or…

Is it something that shouldn’t even be in the app? (I know very little about the GTM and am being asked to add it to the application).

Thank you!

I think the easiest way is to use this add-on GoogleAnalyticsTracker - Vaadin Add-on Directory

I agree that Tatu’s suggestion about the GoogleAnalyticsTracker add-on is likely the most stable route within the Vaadin community.

However, I recently saw a new tool called the GTM Setup Assistant https://stape.io/gtm-set-up-assistant that promises to automate the entire initial GTM setup process (including the switch to server-side). It looks like a huge time saver. I haven’t seen any direct analogs to it yet, but I imagine others might emerge soon.

Has anyone in the Vaadin community tried this Setup Assistant? I’m curious if it’s compatible with Vaadin Flow’s lifecycle and rendering, or if it causes any compatibility headaches. Let me know if you’ve tested it!

Good point - using GoogleAnalyticsTracker really is often the easiest and most stable way to get tracking working in a Vaadin app.
That said, I’m also curious about the tool you mentioned (the GTM Setup Assistant); if someone tried it with Vaadin Flow, would appreciate hearing about any gotchas or what worked. For now I’d stick to GoogleAnalyticsTracker unless I see a clear example that proves GTM Setup Assistant plays nicely with Vaadin life-cycle and navigation.

I have added it to the index.html and on an event (sale) i trigger a JS call to send a google tag event to count a conversion