Skip to content

Conversation

@AnJuHyppolite
Copy link

@AnJuHyppolite AnJuHyppolite commented Dec 9, 2025

Description

This PR implements integrating the GTM container code into the project and sets up the logging function for tracking the unique user metric.

Ticket

This work resolves Google Analytics Setup: Number of unique users (a single prompt).

Approach

  • Added the GTM container code (per Setting up Google Analytics)
  • Implemented the function to track unique user metric (unique_user_prompt)

Steps to Test

  1. Load the app and submit a prompt.
  2. Check the console to see the unique_user_prompt log.

Notes

  • Additional Events will be added in subsequent pull requests.
  • GA4 dashboard setup and data verification still pending

}, [allPlugins, user, setAvailableTools]);

/*NJ: GTM snippet is manually inserted in <head> and <body>, and the use of a custom logEvent() function for analytics
Copy link

Choose a reason for hiding this comment

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

What's the reason for not using the built-in tag manager init code? If we used it, could we skip all the changes in index.html?

Copy link
Collaborator

Choose a reason for hiding this comment

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

that would address my concern as well

(data: { text: string }) => {
submitMessage(data);
const uniqueUserFlagKey: string = 'unique_user_prompt';
if (!window.localStorage.getItem(uniqueUserFlagKey)) {
Copy link

Choose a reason for hiding this comment

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

The analytics question we're trying to answer is "Number of unique users (a single prompt)", right?

In that case, I wouldn't rely on local logic to solve that - instead, we just need to log each time someone makes a prompt (e.g. a "sent prompt" event). Then, when we analyze the data, we can analyze the "sent prompt" event, separating by unique users.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It definitely seems like edits to this file will put us at odds with the upstream. Is there a way we could provide a different index.html in the nj directory and repoint our stuff at that? Maybe not feasible, maybe this is a necessary divergence point.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or Dan's comment about using built-in tag management

@AnJuHyppolite
Copy link
Author

Per PM guidance, analytics requests were for the current version (now complete). Work on v2.0 can start, but this approach may not be necessary, so closing this PR/ticket.

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.

3 participants