Skip to content

feat(frontend): add Google Analytics tracking#263

Merged
ComBba merged 1 commit into
mainfrom
feat/google-analytics
Feb 9, 2026
Merged

feat(frontend): add Google Analytics tracking#263
ComBba merged 1 commit into
mainfrom
feat/google-analytics

Conversation

@ComBba

@ComBba ComBba commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add Google Analytics (gtag.js) to track user behavior

Changes

  • Add next/script with afterInteractive strategy for optimal performance
  • Tracking ID: G-65HJEVF1M4

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@vercel

vercel Bot commented Feb 9, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
somm-dev Ready Ready Preview, Comment Feb 9, 2026 2:32pm

Request Review

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @ComBba, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates Google Analytics into the frontend of the application. By adding the gtag.js script and its configuration to the root layout, the application will now track user behavior, providing valuable insights into user interactions and overall site performance, all while ensuring optimal loading performance through Next.js's script optimization features.

Highlights

  • Google Analytics Integration: Implemented Google Analytics (gtag.js) into the frontend application to enable user behavior tracking.
  • Performance Optimization: Utilized Next.js's next/script component with the afterInteractive loading strategy to ensure the analytics script does not block initial page rendering.
  • Tracking ID Configuration: Configured the Google Analytics tracking ID (G-65HJEVF1M4) within the application's root layout.
Changelog
  • frontend/src/app/layout.tsx
    • Imported the Script component from next/script.
    • Defined a constant GA_ID for the Google Analytics tracking ID.
    • Added two Script components within the html tag: one to load the gtag.js library and another to initialize the dataLayer and configure gtag with the specified GA_ID, both using the afterInteractive loading strategy.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ComBba ComBba merged commit 650800c into main Feb 9, 2026
4 checks passed
@ComBba ComBba deleted the feat/google-analytics branch February 9, 2026 14:34

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request adds Google Analytics tracking to the application using next/script. The implementation is a good start, but there are a couple of areas for improvement. Firstly, the Google Analytics ID is hardcoded, which is not ideal for managing configurations across different environments. It should be moved to an environment variable. Secondly, the tracking scripts are loaded in all environments, including development, which can lead to skewed analytics data. These scripts should only be loaded in production. I've provided specific suggestions to address these points.

import { AuthWrapper } from "@/components/AuthWrapper";
import { SiteHeader } from "@/components/SiteHeader";

const GA_ID = "G-65HJEVF1M4";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The Google Analytics ID is hardcoded. It's a best practice to store configuration values like this in environment variables. This allows for different configurations across environments (development, staging, production) without code changes. For Next.js, you should use a public environment variable by prefixing it with NEXT_PUBLIC_ and adding it to a .env.local file.

Suggested change
const GA_ID = "G-65HJEVF1M4";
const GA_ID = process.env.NEXT_PUBLIC_GA_ID;

Comment on lines +53 to +64
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`}
strategy="afterInteractive"
/>
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_ID}');
`}
</Script>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

These analytics scripts will run in all environments, including local development. This can pollute your analytics data with development activity. It's recommended to only enable analytics in the production environment and to ensure the tracking ID is configured before attempting to load the scripts.

      {process.env.NODE_ENV === "production" && GA_ID && (
        <>
          <Script
            src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`}
            strategy="afterInteractive"
          />
          <Script id="google-analytics" strategy="afterInteractive">
            {`
              window.dataLayer = window.dataLayer || [];
              function gtag(){dataLayer.push(arguments);}
              gtag('js', new Date());
              gtag('config', '${GA_ID}');
            `}
          </Script>
        </>
      )}

ComBba added a commit that referenced this pull request Feb 10, 2026
feat(frontend): add Google Analytics tracking
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