Skip to content

Conversation

@leanhvu21042001
Copy link

Add gtag to global var

  • Content addition

  • Bug fix

  • Behavior change

Summary of change

Fixed Uncaught ReferenceError: gtag is not defined error by ensuring gtag is properly attached to the global window object and adding safety checks before calling it. The track() function in analytics-utils.ts now verifies that window.gtag exists before attempting to call it, preventing runtime errors when the Google Analytics script hasn't loaded yet or in development mode.

Checklist

  • This fix resolves #

  • The changes follow the contributing guidelines

  • I have verified the fix works and introduces no further errors

Changes Made

  1. packages/system/src/util/analytics-utils.ts: Added safety checks to verify window.gtag exists before calling it, preventing ReferenceError when gtag is not available.

  2. packages/site/src/layouts/base.astro: Added window.gtag = gtag; to explicitly attach the gtag function to the global window object in the inline script.

  3. packages/landing-site/src/pages/index.astro: Added window.gtag = gtag; to explicitly attach the gtag function to the global window object in the inline script.

@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for node-framework-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 320134e
🔍 Latest deploy log https://app.netlify.com/projects/node-framework-dev/deploys/692e5e7288063e0008cc006a
😎 Deploy Preview https://deploy-preview-792--node-framework-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for framework-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 320134e
🔍 Latest deploy log https://app.netlify.com/projects/framework-dev/deploys/692e5e72bb87380008a42145
😎 Deploy Preview https://deploy-preview-792--framework-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for vue-framework-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 320134e
🔍 Latest deploy log https://app.netlify.com/projects/vue-framework-dev/deploys/692e5e72d4d1a000083b880a
😎 Deploy Preview https://deploy-preview-792--vue-framework-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for qwik-framework-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 320134e
🔍 Latest deploy log https://app.netlify.com/projects/qwik-framework-dev/deploys/692e5e726c349000085921d9
😎 Deploy Preview https://deploy-preview-792--qwik-framework-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for system-framework-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 320134e
🔍 Latest deploy log https://app.netlify.com/projects/system-framework-dev/deploys/692e5e72559a710008f0ab4f
😎 Deploy Preview https://deploy-preview-792--system-framework-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for angular-framework-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 320134e
🔍 Latest deploy log https://app.netlify.com/projects/angular-framework-dev/deploys/692e5e72e32ed80008e18f9f
😎 Deploy Preview https://deploy-preview-792--angular-framework-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for solid-framework-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 320134e
🔍 Latest deploy log https://app.netlify.com/projects/solid-framework-dev/deploys/692e5e72cc76e800087a3c8b
😎 Deploy Preview https://deploy-preview-792--solid-framework-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for svelte-framework-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 320134e
🔍 Latest deploy log https://app.netlify.com/projects/svelte-framework-dev/deploys/692e5e7296d30300086b17e1
😎 Deploy Preview https://deploy-preview-792--svelte-framework-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for graphql-framework-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 320134e
🔍 Latest deploy log https://app.netlify.com/projects/graphql-framework-dev/deploys/692e5e7296d30300086b17e5
😎 Deploy Preview https://deploy-preview-792--graphql-framework-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for react-framework-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 320134e
🔍 Latest deploy log https://app.netlify.com/projects/react-framework-dev/deploys/692e5e7243096b0009b47aeb
😎 Deploy Preview https://deploy-preview-792--react-framework-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for deno-framework-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 320134e
🔍 Latest deploy log https://app.netlify.com/projects/deno-framework-dev/deploys/692e5e7243096b0009b47aef
😎 Deploy Preview https://deploy-preview-792--deno-framework-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant