File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ declare global {
1111
1212// next/script dedupes by id and never reloads on remount, so this must be
1313// module-scope (not a ref) to survive LandingLayout unmounting/remounting.
14- let hasTrackedInitialPageView = false
14+ // Keyed by URL (not a boolean) so Strict Mode effect replays and same-URL
15+ // remounts never re-fire a PageView already counted for that URL.
16+ let lastTrackedUrl : string | null = null
1517
1618/**
1719 * The X pixel base code only auto-tracks the first page load; LandingLayout
@@ -25,11 +27,15 @@ export function XPageViewTracker() {
2527 const query = searchParams . toString ( )
2628
2729 useEffect ( ( ) => {
28- if ( ! hasTrackedInitialPageView ) {
29- hasTrackedInitialPageView = true
30+ const url = query ? `${ pathname } ?${ query } ` : pathname
31+
32+ if ( lastTrackedUrl === null ) {
33+ lastTrackedUrl = url
3034 return
3135 }
36+ if ( url === lastTrackedUrl ) return
3237
38+ lastTrackedUrl = url
3339 window . twq ?.( 'config' , 'q5xbl' )
3440 } , [ pathname , query ] )
3541
You can’t perform that action at this time.
0 commit comments