gatsby-plugin-google-tagmanager: accept arrays for defaultDataLayer
#36456
Unanswered
mfanuzzi
asked this question in
Ideas / Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let's say you need to set up Google Consent Mode. That requires two objects to be pushed to the top of the dataLayer. With
gatsby-plugin-google-tagmanager
, I expected that I'd be able to pass an array for thedefaultDataLayer
option like so:But this is not supported, it looks like because it wants to just
push
ontodataLayer
the entirety ofdefaultDataLayer
and be done. Reasonable, but it would not be hard to, for example, check ifdefaultDataLayer
is an array, and if so, add them in a loop (or merge/spread, whatever). The same way it conditionally checks if it's a function and executes it if so.Here is my current hack, exploiting the ability for the plugin to call a function:
This works, but it would of course be better and clearer to just be able to pass in array in the first place.
If I or my team get time, we may submit a PR for this if there's interest.
(Side note on that: forking a huge monorepo to make a small contribution kinda stinks; any plans on moving away from the monolith?)
Beta Was this translation helpful? Give feedback.
All reactions