'Integrate Google Analytics directly or via Tag Manager?

I am currently building a large NextJS application. I just need to integrate Google Analytics 4 for the client. Should I rather include Google Analytics directly in my application or include the Tag Manager and configure Google Analytics through it?

I have never really worked with Google Analytics before and I am confused. Theoretically it is more practical to integrate it directly, because I can set dimensions etc. and don't have to configure so much in the Tag Manager?

Thanks



Solution 1:[1]

You should use a tag manager. It abstracts trivial implementations from your codebase and makes it much easier to maintain and scale them without requiring dev resources in vast majority of cases.

On the other hand, if all you'll ever need from analytics are pageviews, then sure, you don't need GTM, just implement it directly and then once you see that you need more, you can move the logic to a tag manager.

GTM is pretty good and free. However, proprietary. Matomo is free and open sourced. Not as good as GTM though. Adobe Launch is probably the best, but it's not free (Adobe doesn't consider it a standalone product) and it requires a bit more skills than GTM. In between, there are also things like Ensighten or Tealium, but they're not very advanced.

Solution 2:[2]

If you only need Analytics on the website, no need to use GTM : you just add Analytics and that's it.

GTM makes tags easier to manage and gives trigger options, so it can be useful :

  • if non-technical people have to manage tags (like the client)
  • if you have several tags and want to manage them all from the same interface
  • if you need triggers and rules that are easy to setup

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BNazaruk
Solution 2 Ben - NokeWeb