🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

feat(nuxt): re-add Google Analytics via nuxt-gtag - #126

Merged
Decipher merged 2 commits into
developfrom
feat/analytics-gtag
Jul 14, 2026
Merged

feat(nuxt): re-add Google Analytics via nuxt-gtag#126
Decipher merged 2 commits into
developfrom
feat/analytics-gtag

Conversation

@Decipher

@Decipher Decipher commented Jul 13, 2026

Copy link
Copy Markdown
Owner

What

Restores GA4 pageview tracking, lost when the legacy nuxt/plugins/gtag.js (vue-gtag) was deleted wholesale as part of the Nuxt 4 rewrite — the deletion was a side effect of replacing the whole legacy tree, not an intentional decision to drop analytics.

  • Adds nuxt-gtag (the maintained Nuxt 3/4-native successor to vue-gtag) and registers it in nuxt.config.ts
  • Reuses the existing GA4 property (G-X1BRPZD4K2) — same site identity, no new property needed
  • Production-only (enabled: !import.meta.dev), matching the old plugin's dev-skip behaviour
  • SPA route-change tracking comes from nuxt-gtag's built-in router integration (site is fully prerendered, no manual plugin needed)
  • Documents the dependency in AGENTS.md's tech-stack list so it isn't silently dropped again in a future rewrite

Verification

  • pnpm typecheck — clean
  • pnpm lint — clean
  • pnpm test — 415/415 passing
  • pnpm generate — confirmed G-X1BRPZD4K2 / googletagmanager present in generated dist/index.html
  • Manually verified via a live Cloudflare tunnel of the generated production build — GA4 Realtime picked up the pageview and a subsequent SPA route change

Mirrors GitLab MR !18 (this repo's primary development happens on GitLab; this PR keeps GitHub in sync). See openspec/changes/add-analytics-gtag/ (workspace root repo) for the full proposal.

Restores GA4 pageview tracking (property G-X1BRPZD4K2), lost when the
legacy nuxt/plugins/gtag.js was deleted wholesale as part of the Nuxt 4
rewrite. Uses nuxt-gtag (the Nuxt 3/4-native successor to vue-gtag) instead
of porting the old plugin; production-only via enabled: !import.meta.dev,
matching the old plugin's dev-skip behaviour. SPA route-change tracking
comes from nuxt-gtag's built-in router integration — no manual plugin
needed since the site is fully prerendered.

See openspec/changes/add-analytics-gtag/ for the proposal.
@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for stuartc ready!

Name Link
🔨 Latest commit 5bdb60e
🔍 Latest deploy log https://app.netlify.com/projects/stuartc/deploys/6a555c5f0919060008781684
😎 Deploy Preview https://deploy-preview-126--stuartc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Decipher, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 40a3a913-58c5-4663-9591-7dc4fe0ec1b6

📥 Commits

Reviewing files that changed from the base of the PR and between 5c14b1a and 5bdb60e.

📒 Files selected for processing (1)
  • nuxt/nuxt.config.ts
📝 Walkthrough

Walkthrough

Added nuxt-gtag to the Nuxt application, configured production-only GA4 tracking with measurement ID G-X1BRPZD4K2, added the package dependency, and documented the integration.

Changes

GA4 analytics integration

Layer / File(s) Summary
Configure production GA4 tracking
nuxt/nuxt.config.ts, nuxt/package.json, AGENTS.md
Registers nuxt-gtag, configures the GA4 measurement ID and development gating, adds version ^4.1.0, and documents the production-only analytics setup.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: renovate[bot]

Sequence Diagram(s)

sequenceDiagram
  participant NuxtApp
  participant NuxtGtag
  participant GA4
  NuxtApp->>NuxtGtag: Initialize when not in development
  NuxtGtag->>GA4: Send events for G-X1BRPZD4K2
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: re-adding Google Analytics through nuxt-gtag in the Nuxt app.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/analytics-gtag

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@nuxt/nuxt.config.ts`:
- Around line 37-40: Update the gtag.enabled configuration in nuxt.config.ts to
use the host’s explicit production deploy context, such as NETLIFY_CONTEXT ===
'production', instead of import.meta.dev. Ensure GA4 events are enabled only for
the canonical production deployment and remain disabled for previews and branch
builds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 12bfe54f-2ed9-4ac4-b771-8b8e52f5c953

📥 Commits

Reviewing files that changed from the base of the PR and between f3e4395 and 5c14b1a.

⛔ Files ignored due to path filters (1)
  • nuxt/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • AGENTS.md
  • nuxt/nuxt.config.ts
  • nuxt/package.json

Comment thread nuxt/nuxt.config.ts
enabled: !import.meta.dev fired on any non-dev build, including this PR's
own deploy preview and future branch deploys — both send real traffic
into the production GA4 property. Restrict to NETLIFY_CONTEXT === 'production'
instead. Caught by CodeRabbit review on PR #126.
@Decipher
Decipher merged commit bd6acb6 into develop Jul 14, 2026
10 checks passed
@Decipher
Decipher deleted the feat/analytics-gtag branch July 14, 2026 00:27
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