OpenZeppelin / OpenZeppelin/openzeppelin-ui

AnalyticsService: page_view double-counted when apps also call trackPageView

Open
#223 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7
Forks
3
Avg merge
20h 20m
Merged PRs (30d)
26

Description

Problem

AnalyticsService.initializeGtag (packages/utils/src/AnalyticsService.ts, line ~175) calls gtag('config', tagId) without send_page_view: false, so gtag emits its automatic page_view on load. Apps that also track route changes via trackPageView (Role Manager and RWA Wizard both mount a TrackedRoute component) therefore send two page_view events on first landing — inflating page-view counts in GA4 by one per session. UI Builder is unaffected because it never calls trackPageView.

Surfaced while wiring GA4 custom dimensions for the analytics pipeline (OpenZeppelin/rwa-wizard#63).

Suggested fix

Either:

  • Add a sendPageView option (default true to preserve current behaviour) to AnalyticsService.initialize / AnalyticsProvider, passed through as gtag('config', tagId, { send_page_view }), so apps with route tracking can opt out; or
  • Flip the default to send_page_view: false and document that apps must call trackPageView (breaking for apps relying on the automatic hit).

Consumers to update after release: role-manager and rwa-wizard TrackedRoute usages.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/utils/src/AnalyticsService.ts at AnalyticsService.initializeGtag around line 175, then trace initialize, AnalyticsProvider, and trackPageView. Inspect the TrackedRoute usages in Role Manager and RWA Wizard, while noting that UI Builder does not call trackPageView. Done means the chosen behavior is supported and those route-tracking apps no longer send a duplicate first-landing page_view without breaking existing automatic tracking.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
analytics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.