Skip to content

Track video plays and progress on FAQ video embeds - #201

Merged
vpetersson merged 1 commit into
sbomify:masterfrom
vpetersson-bot:track-faq-video-plays
Nov 28, 2026
Merged

vpetersson merged 1 commit into
sbomify:masterfrom
vpetersson-bot:track-faq-video-plays

Conversation

@vpetersson-bot

Copy link
Copy Markdown
Contributor

What

Adds PostHog events for the self-hosted <video> embeds (video-embed-native), which is what every FAQ screencast uses:

  • video_play: sent once per video per page view.
  • video_progress with percent: sent at 25, 50, 75 and 100 (on ended). Each milestone is sent once, even if the visitor seeks back or replays.
  • The first play also calls register_for_session({ watched_video: true }). Every later event in that session carries the flag, cta_click included, so a "watched a video → clicked sign-up" funnel can be built without new CTA code.

Each event carries video_title, video_url and site_section, the same section value cta_click uses. To see only FAQ traffic, filter on site_section = faq.

Why

Today no event fires when someone plays a video, so we can't tell whether the FAQ videos are watched, or whether watching them leads to a click through to the app.

How

The change is a single capture-phase listener on document for play, timeupdate and ended. Media events don't bubble, but capture-phase listeners still see them, so no per-embed script is needed. It lives in layouts/partials/posthog.html next to the cta_click tracker and follows the same consent rules: nothing is sent unless the visitor has opted in and PostHog has loaded. The shortcode also gains a data-video-title attribute so events are labelled.

No new script file and no extra request, so PageSpeed is unaffected.

YouTube iframe embeds (video-embed) are not covered. Clicks inside a cross-origin iframe can't be seen without the YouTube iframe API, and none of the FAQ pages use them.

Testing

  • hugo --minify --environment production builds cleanly, and the FAQ pages contain the listener and the data-video-title attribute.
  • Ran the built FAQ page's script in jsdom with a stubbed PostHog and simulated playback: play, 30%, 60%, pause, play, 80%, 80%, ended, ended, then a sign-up link click. The result was one video_play and one each of 25/50/75/100 video_progress, with no duplicates. The cta_click that followed carried watched_video: true.

🤖 Generated with Claude Code

The site sent no event when a visitor played one of the self-hosted
screencasts (every FAQ video), so there was no way to see whether the
videos are watched or whether watching leads to a sign-up.

A capture-phase listener in the PostHog partial now sends video_play
once per video per page view and video_progress at 25/50/75/100%. The
first play registers watched_video for the session, so later events,
cta_click included, carry it for funnel filtering. Like cta_click, it
only fires once the visitor has consented and PostHog is loaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vpetersson
vpetersson merged commit 170ab0a into sbomify:master Nov 28, 2026
3 checks 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.

2 participants