how to integrate Tag Manager #216
-
Hello fellow forum members, I hope you're all doing well. I have a question regarding the integration of Google Tag Manager (GTM), and I was wondering if someone could kindly provide me with some guidance. Could someone please help me by elaborating on the process of integrating Google Tag Manager into a website theme? What are the steps I need to follow? How do I set up tags and triggers within GTM? Any tips or best practices would be greatly appreciated. Thank you in advance for your assistance! Your expertise will be invaluable in helping me understand and successfully implement Google Tag Manager. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello @mikkivirus-dev I don't know the configuration details of the Google Tag Manager because I have never used it, although I know that it allows you to inject scripts into the pages. There is a way, for example, to inject Google Analytics using Google Tag Manager. I can suggest you in which file of the template you can place the code provided by Google Tag Manager, from that place it will fire on all the pages of the website: https://github.com/onwidget/astrowind/blob/main/src/layouts/Layout.astro Another user can help you with the other details you need. Thank you |
Beta Was this translation helpful? Give feedback.
-
@prototypa I also wanted to add Google Tag Manager to my project, I followed the same pattern as your @astrolib/analytics package for Google Analytics. It's just one extra/alternate script (Google will disable your site's GA4 tags and force you to go through GTM if you create a GTM property for your website). You are welcome to it, anyone else may use it as well. Tested and working on localhost in Google Tags Debug Mode and on my website deployed to production. Semi-packaged code is here. |
Beta Was this translation helpful? Give feedback.
@prototypa I also wanted to add Google Tag Manager to my project, I followed the same pattern as your @astrolib/analytics package for Google Analytics. It's just one extra/alternate script (Google will disable your site's GA4 tags and force you to go through GTM if you create a GTM property for your website).
You are welcome to it, anyone else may use it as well.
Tested and working on localhost in Google Tags Debug Mode and on my website deployed to production.
Semi-packaged code is here.
Other necessary updates to configBuilder.ts and config-schema.json are here.
As well as config.yaml updates here.
Then add two new components to src/components/common, BodyTag here, HeadTag here.
Then in…