Skip to content

Conversation

Debatty-Tom
Copy link
Contributor

@Debatty-Tom Debatty-Tom commented Oct 9, 2025

Cover #23.

Added gtm method which display the good script tag if user consent.

If a GTM id is set in the .env at the GOOGLE_TAG_MANAGER_ID key or in the config/cookieconsent.php file, the default script for gtm is set to denied the google tag manager access.

In the config, you will also find the gtm_consent key, which is an array of the different categories of cookies defined by Google Tag Manager that you can modify.

Google Analytics and Google Tag Manager use the same cookies which means it's not necessary to use both. If you only need Google Anlaytics, use the google method. If you need the Google Tag Manager you can use the gtm method.

Copy link
Member

@toonvandenbos toonvandenbos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I'm not a fan of this approach.

I know there is currently a Google Analytics configuration in this package's config file, but I don't think it should stay there. The goal is to avoid polluting this config file with potential options for every possible use case. Instead, I think it would be better to provide the needed configurations as arguments to the ->google() & ->gtm() methods when they are used.

Also, since both are "google" shortcuts, I'd recommend using better method names:

  • googleAnalytics()
  • googleTagManager()

Finally, did you test this with a real Google Tag Manager setup?

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

Successfully merging this pull request may close these issues.

2 participants