Skip to content

bugfix(site): analytics - ga4 initialization - #52

Merged
suejinkim20 merged 5 commits into
stagecc:mainfrom
suejinkim20:bugfix/analytics-ga4-initialization
Aug 20, 2026
Merged

bugfix(site): analytics - ga4 initialization#52
suejinkim20 merged 5 commits into
stagecc:mainfrom
suejinkim20:bugfix/analytics-ga4-initialization

Conversation

@suejinkim20

@suejinkim20 suejinkim20 commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

This PR is the first part of a two-part analytics update.

It moves GA4 initialization out of AnalyticsController.tsx and into the <head> of Base.astro, and it renames the environment variable from PUBLIC_GTM_ID to PUBLIC_GA_ID.

This change prepares the site to use the new direct GA4 analytics setup. A follow-up PR will implement specific tracking behavior on top of that foundation.

Analytics events are being sent to google analytics and have been confirmed in the dashboard.

@suejinkim20
suejinkim20 requested a review from mbwatson August 20, 2026 16:08

@mbwatson mbwatson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe mention in the PR description that this is a two-parter--one that preps to use the new analytics solution (this one), and another that implements specific tracking.

i see ```Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app
    See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.```

logged upon request for any route, so some refactoring must be in order there or maybe just a swap to use client:only="react".

lastly, be sure to keep documentation in line with changes.

Comment thread apps/site/sample.env
@suejinkim20
suejinkim20 requested a review from mbwatson August 20, 2026 18:12

@mbwatson mbwatson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice fixes. seems to be working!

because the analytics stuff is not inherently tied to React, i'd say long-term i'd like to see this in plain javascript. notice this is only an effect that returns null, so this is effectively a script with React overhead.

Comment thread apps/site/README.md Outdated

Dug search interactions push analytics events to `window.dataLayer`.
To route those events to GA4, configure Google Tag Manager and set:
This app uses direct Google Analytics 4 with `gtag.js`, not Google Tag Manager. Analytics events may still pass through `window.dataLayer` as part of the standard GA4 setup.`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nitpick: trailing backtick on this line

@suejinkim20
suejinkim20 merged commit f4ba488 into stagecc:main Aug 20, 2026
5 checks passed
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.

2 participants