Skip to content

feat(analytics): fire the page view once the player is known - #20

Merged
vpetersson-bot merged 1 commit into
masterfrom
feat/attribute-page-view
Aug 15, 2026
Merged

feat(analytics): fire the page view once the player is known#20
vpetersson-bot merged 1 commit into
masterfrom
feat/attribute-page-view

Conversation

@vpetersson-bot

Copy link
Copy Markdown
Contributor

Bumps @screenly-labs/signage-kit to 2026.8.10 and moves the page view so it carries the player fields.

The problem

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 (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:

app page views attributed run attribution
Quotes 9,996 3,168 32%
Timer 5,986 1,385 23%
World Clock 4,579 1,241 27%
Menu Board 1,794 395 22%

Against 87 to 92% on the Worker apps.

The change

Two lines that must stay together:

<script>gtag('config', 'G-XXXXXXX', { send_page_view: false })</script>
trackPlayer(detectPlayer(), { app: '...', sendPageView: true })

trackPlayer fires the page view one line after the user properties, in exactly the position player_detected already 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.js now reports nothing at all rather than an unattributed page view. player_detected lands 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

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>
@vpetersson-bot
vpetersson-bot merged commit 2eec802 into master Aug 15, 2026
1 check passed
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