feat(analytics): fire the page view once the player is known - #20
Merged
Conversation
The automatic `page_view` goes out with `gtag('config')`, before `main.js` can profile
the player, so it carries no player fields. `trackPlayer` runs afterwards and only its
own events are attributed.
This is not the client_id churn that motivated the Worker-app fix. These screens keep
their identity across hundreds of loads; the loss is per LOAD. Measured 2026-08-14,
Quotes sent 9,996 page views and only 3,168 carried player fields, which is why the
static apps sat at 22-46% run attribution against 87-92% on the Worker apps.
So the tag is configured with `send_page_view: false` and `trackPlayer` sends the page
view itself, one line after the user properties, in exactly the position
`player_detected` already occupies. The two settings pair: set one without the other
and the app either double-counts every page view or stops counting them.
The trade is that a load which never reaches `main.js` now reports nothing at all
rather than an unattributed page view. That is measured, not assumed:
`player_detected` lands on 99.7% to 100% of page views on every static app, so 0.3% or
less of loads go silent. A Worker app has the profile before it configures, so it keeps
the automatic page view instead and cannot lose one.
Kit bumped to 2026.8.10, which adds the option.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Bumps
@screenly-labs/signage-kitto2026.8.10and moves the page view so it carries the player fields.The problem
The automatic
page_viewgoes out withgtag('config'), beforemain.jscan profile the player, so it carries no player fields.trackPlayerruns afterwards and only its own events are attributed.This is not the
client_idchurn that motivated the Worker-app fix (signage-kit#32). These screens keep their identity across hundreds of loads. Quotes recorded 28 client_ids across ~357 loads each. The loss is per load.Measured 2026-08-14 across the static apps:
Against 87 to 92% on the Worker apps.
The change
Two lines that must stay together:
trackPlayerfires the page view one line after the user properties, in exactly the positionplayer_detectedalready occupies, and that event is attributed on essentially every load. Set one without the other and the app either double-counts every page view or stops counting them, so both call sites carry a comment pointing at the other.The trade, measured
A load that never reaches
main.jsnow reports nothing at all rather than an unattributed page view.player_detectedlands on 99.7% to 100% of page views on every static app, so 0.3% or less of loads go silent, against 68% currently carrying no player fields.A Worker app has the profile in hand before it configures, so it keeps the automatic page view and sets the properties first, which cannot lose a page view. That is why this option is off by default and the Worker apps do not use it.
Kit side: Screenly-Labs/signage-kit#33
🤖 Generated with Claude Code