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

Allow specifying custom "gtag" function name #67

Open
felixarntz opened this issue Aug 26, 2024 · 0 comments
Open

Allow specifying custom "gtag" function name #67

felixarntz opened this issue Aug 26, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@felixarntz
Copy link
Collaborator

Follow-up to #53: Per this code, instead of using gtag for the function name, Google Analytics via TPC uses gtag-{dataLayerName}.

This can seem a bit odd, given that for example gtag-dataLayer does not look like a function name. In many projects, events are added by simply calling gtag() (not window.gtag() or window[ 'gtag' ]()), but you won't be able to call gtag-dataLayer in that way because it doesn't follow JS function name syntax.

While it is possible for consumers to wrap the code, it may be a more intuitive and easier-to-use solution to have built-in support.

Maybe we could introduce a new optional param for the function name to use in place of gtag? This would probably be more intuitive. On the downside, someone could pass "gtag" and still use that name, which we may not want, given it can lead to conflicts between multiple Analytics configurations. Alternatively, a new optional param for just the suffix after the gtag could be used. For example:

  • New param for the gtag function suffix
  • Example value: MyProduct
  • Result: The function is available as gtagMyProduct(), which means it can also be accessed directly like a JS function.

cc @flashdesignory

@felixarntz felixarntz added the enhancement New feature or request label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants
@felixarntz and others