Google tag manager or code injection - what's better?

Hi all,

I’m just sitting here wondering about a thing: what is the more effective/efficient way to add scripts to one’s site: using Google Tag Manager or putting straight into the code injection in Ghost admin?

To be clear, I’m wondering about this in terms of performance, not what might be the most convenient way for a user. Ghost caching having any benefits?

My usecase is a handful of scripts: analytics, some affiliate things and such.

I use tag manager but that’s just because I imagined it’s a smart thing to do, in reality, I don’t have a clue. Someone who knows these things better?

Bumping this to see if someone has an opinion?

Originally posted same day as the launch of Ghost 4 so this obviously got lost in the news.

I’ve added GA in my theme instead of as an injection. This because of, as I understand it, the theme template files are loaded first - then injections. I might be wrong, but it’s working fine for me.

Google Tag Manager is better if you have lots of scripts and conversion tracking setup.

Performance-wise, if you’re using GTM for just analytics, or just one bit of code, it’s actually less efficient in my experience. But if you’re using quite a few bits of code, it’s nice to be able to control everything from one dashboard and also being able to add or remove code directly from that same dashboard - on the fly!

  • Alright thanks for sharing your views. Actually, I’m still wondering about my very question: is there any difference between using GTM or simply code injection performance-wise, that is in terms of speed and such. What do I know, maybe there’s no difference at all? Thanks anyway -

I have placed the Google Tag Manager scripts in default.hbs file. Will it work? Or should I be doing anything else?

Yeah I tried that too. It works. I’m still interested in what is the optimal way in terms of performance. Maybe someone has an oponion?

That’s what I did as well and it works fine. I’m using anonymous IP, which also works fine.

There should not be any performance issues as the script runs with the defer tag.

1 Like