Ghost code injection fine tunning for Google Tag Manager

Hey all,

Just a quick idea on the Ghost code injection, in relation to Google Tag Manager:

  • does it make sense to add a section of code injection also right after the opening tag?
  • the idea is that the standard Google Tag Manager implementation requires a two part tracking code to be inserted (one in header and one in body)
  • I know it’s kind of a single exception, but it would allow for much more flexibility as all other tags could be fired through GTM and would make the Ghost code injection cleaner

Thanks!

Also, for post injection, I know there is the option to inject something different in every post, but I also think that a global before/after post (not just header/footer) injection would be useful as well (especially for those wanting to monetize their Ghost blog/publication in any way).

1 Like

All your problems can be solved by modifying the theme. I don’t think a code injection right after the opening tag would be useful. Simply edit your default.hbs and put your code in there, after <body>. For global before/after post you can edit post.hbs and inject the desired code in there. No need for extra fields in Ghost admin.

2 Likes

By the same token neither the current code injection feature isn’t useful as any code can be added to the theme files. :wink:

While I agree with you, I think that for non tech users an option in the admin is useful as it reduces the required theme hacks.

2 Likes

And reduces issues that can arise from theme updates or ghost updates. The more vanilla, the easier.

Hi,

Indeed, it would be so much appreciated to have the option to insert a code into the theme (and not only into the header or footer) directly via the interface (e.g. for GTM purposes).

Anyway, I’ve tried the manipulation (even thought I am not technical) and here’s my issue:

  • I need to download the theme to be able to mofify the file default.hbs
  • the I am able to modify the file adding my tag
  • however, when I download my zip into Ghost, I am requested to give a different name than the original template, so I do and I can then activate my new template
  • Here problem: I have an 505 error message on my blog saying “ENOENT: no such file or directory, open ‘/home/ghost/content/themes/casper–1-/default.hbs’”

Any idea where do I need to change the path to the new template name ???