fix(ga4): 再入場 page_view を config 再実行に変更し (not set) を解消 - #26
Open
appdevelopsk wants to merge 1 commit into
Open
Conversation
2026-09-08 の PR #14 が入れた reenter() は gtag('event','page_view') を 送っていたが、event スコープの page_view はページコンテキストを張り直さない。 そのため 30分アイドル後のタブ復帰で始まる新セッションは landingPage を 決定できず「(not set) / Unassigned」に落ちていた。Unassigned は 17→64 と 逆に増えていた。 また、この経路のセッションはスクロール/クリックを一度もしていない (lastActivity を更新するのはその2つだけ)ため、エンゲージメント率が 構造的に 0 になる。監査の「46セッション / ER 0」はこの層と一致する。 gtag('config', GA_ID, {send_page_view:true, page_location, page_path, page_title}) の再実行に置き換え、ページコンテキストごと張り直す。 GA_ID は layout.tsx の <head> 直書き config と同じ解決順にした。 Claude-Session: https://claude.ai/code/session_01D41rnpZ7nmdkNHNJgWn2wp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題
2026-09-08 の PR #14「GA4 Unassigned 対策」で追加した
reenter()が、狙いと逆に Unassigned を 17 → 64 に増やしていた。原因
reenter()はgtag('event', 'page_view', {...})を送っていた。event スコープのpage_viewはページコンテキストを張り直さないため、30分アイドル後のタブ復帰で始まる新セッションは landingPage / チャネルを決定できず(not set) / Unassignedに落ちる。さらにこの経路のセッションは定義上スクロールもクリックもしていない(
lastActivityを更新するのはその2つだけ)ので、エンゲージメント率が構造的に 0 になる。監査が報告した「46セッション / ER 0」の層と一致する。修正
gtag('config', GA_ID, { send_page_view: true, page_location, page_path, page_title })の再実行に置き換え、ページコンテキストごと張り直す。GA_IDはlayout.tsxの<head>直書き config と同じ解決順(NEXT_PUBLIC_GA_MEASUREMENT_ID→G-M7SF83B60R)。検証
tsc --noEmitエラー0https://claude.ai/code/session_01D41rnpZ7nmdkNHNJgWn2wp