Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Tracking events when gtag not set up #24

Closed
nandi95 opened this issue Aug 29, 2023 · 1 comment
Closed

Tracking events when gtag not set up #24

nandi95 opened this issue Aug 29, 2023 · 1 comment

Comments

@nandi95
Copy link

nandi95 commented Aug 29, 2023

Environment

latest

Reproduction

set up module but don't set an id (happens in development)

Describe the bug

The module only sets up with dataLayer on the window when the id has been set.

if (!id)
return
window.dataLayer = window.dataLayer || []

The trackEvent etc expects the window.dataLayer to be set.

export function gtag(..._args: any[]) {
// eslint-disable-next-line prefer-rest-params
window.dataLayer!.push(arguments)
}

This should not have that assertion and should have a check for the existence of the id or the dataLayer.

Am I missing something?

Additional context

No response

Logs

No response

@johannschopplich
Copy link
Owner

Thanks for pointing that out!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants