Skip to content
This repository was archived by the owner on Apr 20, 2026. It is now read-only.

Add GA4 tracking for chat_send and knowledge_generate events - #61

Open
kromiii wants to merge 1 commit into
mainfrom
codex/add-ga4-tracking-for-chat-and-knowledge-events
Open

Add GA4 tracking for chat_send and knowledge_generate events#61
kromiii wants to merge 1 commit into
mainfrom
codex/add-ga4-tracking-for-chat-and-knowledge-events

Conversation

@kromiii

@kromiii kromiii commented Apr 19, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Record user interactions (chat sends) and knowledge-generation actions as GA4 events so product/usage analytics can track these key behaviors.

Description

  • Add a reusable trackAnalyticsEvent helper in app/chat/ChatClient.tsx that safely pushes events to dataLayer for GTM/GA4 consumption.
  • Emit a chat_send event from handleSubmit with web_search_enabled and message_length parameters when a user sends a message.
  • Emit a knowledge_generate event from handleTurnIntoKnowledge on successful digest generation with a message_count parameter.
  • Implementation assumes GTM is loaded via NEXT_PUBLIC_GTM_ID in app/layout.tsx so dataLayer will be processed by GTM/GA4.

Testing

  • Ran npm run lint and the linter completed with no errors.

Codex Task

@vercel

vercel Bot commented Apr 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
today-i-learned Ready Ready Preview, Comment Apr 19, 2026 1:16pm

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant