-
-
Notifications
You must be signed in to change notification settings - Fork 14
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 option to use custom dataLayer variable #401
Conversation
Abitlity to rename dataLayerName in window.
@Shinigami92 I refactored the code based on your reviews. Those made sense, and I'm sorry for not noticing the use of Let me know if the changes make sense for you, as I did create a reusable function to get or construct the |
This pull request introduces the ability to change the name of the
dataLayer
used by GTM. The new feature allows passing an option calleddataLayerName
, which initializes a window variable that contains the dataLayer array and changes helper methods such aspush()
,trackEvent()
, andtrackView()
to push data to this renamed dataLayer variable.When fetching Tag Manager's script, this uses Google's recommendation to pass the dataLayerName as a query parameter.