-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat(GA,GTM): configurable dataLayer name #163
Conversation
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, assuming the imports are good as is π
@@ -13,32 +12,27 @@ export interface TpcDescriptor { | |||
tpcTypeImport: string | |||
key: string | |||
registry?: any | |||
options: ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any particular reason to change this? this matches the useRegistryScript
interface so keeps code closer aligned
|
||
declare global { | ||
interface Window extends GoogleTagManagerApi {} | ||
} | ||
export type GoogleTagManagerInput = RegistryScriptInput<typeof GoogleTagManagerOptions> | ||
|
||
export function useScriptGoogleTagManager<T extends GoogleTagManagerApi>(_options?: GoogleTagManagerInput) { | ||
_options = defu(_options, { dataLayerName: 'defaultGtm' }) | ||
return useRegistryScript<T, typeof GoogleTagManagerOptions>(_options?.key || 'google-tag-manager', options => ({ | ||
scriptInput: { | ||
src: withQuery('https://www.googletagmanager.com/gtm.js', { id: options?.id }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the src needs to include the dataLayer name otherwise how will it link it π€
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm it's not in TPC π . Is there a default name for data layers ?
cc @flashdesignory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait I just merged this and I forgot I left this comment.
Can we do some testing on it and make sure it's actually working? I'm pretty sure it will just use dataLayer
if not configured.
cc: @flashdesignory
Personally, I'd prefer to see the default behaviour to use Is using |
The idea of the we can revert back to the previous implementation, where we'd use |
Oh my mistake, I didn't realize this is how it was baked into TPC. We can go with this solution to move this along. Some doc for end-users on which window var is set may be useful. |
π Linked issue
#154
β Type of change
π Description
Update to tpc 1.1.1 with minor changes.
dataLayerName
to avoid conflicts between gtm and gadefaultGa
for google analyticsdefaultGtm
for google tag manager