GTM vs gtag

razbakov

Aleksey Razbakov

Posted on January 11, 2020

GTM vs gtag

What's the benefit of using Google Tag Manager (GTM) instead of gtag?

As a Developer you have full control of what data will be sent to GoogleAnalytics (GA) with gtag and you don't need to configure it twice (gtag in code + GTM tag with trigger and variable).

I see so far few possible benefits:

  • It tracks generic events like page_view on history_change, scroll, video_play, etc.
  • Add HTML snippets for FacebookPixel or some ChatWidgets with some conditions (specific page, event) but isn't it more reliable and under control with source code?
  • Configure event mapping for FacebookPixel, etc.?
  • If you configure GTM trigger as click on button and send event without a need to add an event in code but it's unreliable solution, because once code is changed it will be difficult to figure out what's broken
  • If you push in dataLayer context, so instead of sending
gtag({ event: "search", search_term: "keyword" })

you send

gtag({ action: "search", search_term: "keyword" })
gtag({ event: "submit" })

but then you can figure out in GTM which variables to use, but this will require to do a lot of conditions in GTM to define different logic for each event

There is no simple way just to forward all events from GTM to GA, if you forward all events it will also forward all gtm events like: gtm.start, gtm.history, etc. So the workaround is to use:

{ event: "interaction", action: "search" }

But also in this case you will need extra conditions if you want to send different context for different events.

I like GTM. I like how it works and how it looks. I just don't understand benefit of using it, while you can do things faster and better with gtag.

💖 💪 🙅 🚩
razbakov
Aleksey Razbakov

Posted on January 11, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

What should I choose Next.js or Remix?
javascript What should I choose Next.js or Remix?

February 15, 2022

GTM vs gtag
javascript GTM vs gtag

January 11, 2020