Repository navigation
Track video plays and progress on FAQ video embeds - #201
Merged
Merged
Conversation
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
approved these changes
Nov 28, 2026
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.
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_progresswithpercent: sent at 25, 50, 75 and 100 (onended). Each milestone is sent once, even if the visitor seeks back or replays.register_for_session({ watched_video: true }). Every later event in that session carries the flag,cta_clickincluded, so a "watched a video → clicked sign-up" funnel can be built without new CTA code.Each event carries
video_title,video_urlandsite_section, the same section valuecta_clickuses. To see only FAQ traffic, filter onsite_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
documentforplay,timeupdateandended. Media events don't bubble, but capture-phase listeners still see them, so no per-embed script is needed. It lives inlayouts/partials/posthog.htmlnext to thecta_clicktracker and follows the same consent rules: nothing is sent unless the visitor has opted in and PostHog has loaded. The shortcode also gains adata-video-titleattribute 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 productionbuilds cleanly, and the FAQ pages contain the listener and thedata-video-titleattribute.video_playand one each of 25/50/75/100video_progress, with no duplicates. Thecta_clickthat followed carriedwatched_video: true.🤖 Generated with Claude Code