Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[add-resource] New Plugin - to add Google Tag Manager Container code to the Grav CMS #3845

Closed
jaymurphy1997 opened this issue Aug 4, 2024 · 6 comments

Comments

@jaymurphy1997
Copy link

Hello:

I would like to add my new plugin, which ads the Google Tag Manager Container code to the head and foot positions of a Grav website without and code changes in the template or pages.

The project lives here https://github.com/jaymurphy1997/grav-plugin-gtm-plugin

I plan to make further updates - as both Grav CMS and Google Tag Manager will be part of my business going forward.

Best regards,
Jay Murphy

@rhukster
Copy link
Member

rhukster commented Aug 8, 2024

Added to GPM

@rhukster rhukster closed this as completed Aug 8, 2024
@rhukster
Copy link
Member

rhukster commented Aug 8, 2024

Won't show up until you do a proper release though: https://learn.getgrav.org/17/advanced/grav-development#theme-plugin-release-process

@pamtbaau
Copy link
Contributor

Took the liberty to have a look at the plugin.

A small and simple plugin which nonetheless could benefit from some improvements:

  • The inline code is added correctly.
  • The <noscript> tag is not being inserted.

Code suggestions:

  • Stick to the layout of the file generated by bin/plugin devtools
    • Add extra events in onPluginsInitialized, as shown in the generated plugin skeleton and also as shown in the docs.
      When adding events to getSubscribedEvents unexpected side effects could occur.
  • You've created a comment "// Don't proceed if there is no GTM Container ID", but the code does not test for an empty GTM containder Id.
  • During event onAssetsInitialized Grav has not yet generated any output. This is why the <noscript> is not being inserted.
    • Did you test/debug it?
  • Take a look at the docs about Event Hooks and Grav Lifecycle to learn when the output has been generated.

Readme:

  • The Configuration example does not match the gtm-plugin.yaml file.
  • The Usage section might be expanded a bit by explaining how and where the container Id should be added (file vs Admin).
    There are many unexperienced users and users who only use Admin.

@jaymurphy1997
Copy link
Author

jaymurphy1997 commented Aug 23, 2024 via email

@pamtbaau
Copy link
Contributor

I did not realize this was live.

It isn't live until you create a proper release as mentioned above. I just cloned your repo.

@jaymurphy1997
Copy link
Author

I have addressed all the comments by @pamtbaau from above and created a "0.1.0-alpha" release. I plan to add more functionality over time as well as address any issues that arise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants