You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Follow-up to #53: Per this code, instead of using
gtag
for the function name, Google Analytics via TPC usesgtag-{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 callinggtag()
(notwindow.gtag()
orwindow[ 'gtag' ]()
), but you won't be able to callgtag-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 thegtag
could be used. For example:gtag
function suffixMyProduct
gtagMyProduct()
, which means it can also be accessed directly like a JS function.cc @flashdesignory
The text was updated successfully, but these errors were encountered: