Skip to content

Use useVideoAttentionTracking for tracking YouTube player attention time#16178

Open
SHession wants to merge 2 commits into
mainfrom
sh/add-component-attention-tracking-to-youtube-player
Open

Use useVideoAttentionTracking for tracking YouTube player attention time#16178
SHession wants to merge 2 commits into
mainfrom
sh/add-component-attention-tracking-to-youtube-player

Conversation

@SHession

Copy link
Copy Markdown
Contributor

What does this change?

As requested by the Ophan team, the current implementation of the YouTube player means attention times under-report as there may be little engagement when a video is playing. The historic mechanism to ensure Ophan continues to tracking attention time for video has long been unused.

This PR adds component attention time and ensures page attention time is captured by using the useVideoAttentionTracking hook implemented into the SelfHosted video player. That hook ensure attention time updates continue to be sent by dispatching events the Ophan tracker expects/

Hook:

dispatchOphanAttentionEvent('videoPlaying');

dispatchOphanAttentionEvent('videoPause');

Ophan
Ophan Tracker JS - Attention Tracking

Why?

This PR will improve the attention time tracking for YouTube videos as requested by the Ophan team.

@github-actions

Copy link
Copy Markdown

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

@SHession SHession added the feature Departmental tracking: work on a new feature label Jun 16, 2026
const id = `youtube-player-${uniqueId}`;

const [isInView, setNode] = useIsInView({
debounce: true,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was seeing some inconsistent behaviour on YouTube videos on Fronts in Safari. Adding debounce seemed to help. Would value a second opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Departmental tracking: work on a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant