Amphtml: AMP video analytics sending duplicate vsession and video-seconds-played events while video-percentage-played events are not sending

Created on 24 Aug 2020  路  11Comments  路  Source: ampproject/amphtml

What's the issue?

On an AMP story with multiple pages:

  1. After the first video/page, video-percentage-played events will not be sent.
  2. If user taps through multiple pages (7+) in a very short time (e.g. 3 seconds), the AMP story page will send vsession and video-seconds-played events every time the event is triggered for the video that is not currently playing.

How do we reproduce the issue?

  1. Go to https://fireworktv.com/ch/mesh/embed
  2. Quickly tap the video 7 times, wait and tap one more time
  3. Expected: Only video events will be triggered for the currently playing video including the video-percentage-played event
  4. Result: Multiple video events (e.g. vsession) are triggered at the same time, including the videos that are not playing. At the same time, video-percentage-played events are not triggered

What browsers are affected?

All browsers

Which AMP version is affected?

Version 2007302351001

@ampproject/wg-ui-and-ally

Soon Bug stories

Most helpful comment

We short circuit the video's layoutCallback (in amp-video), because we want it to be handled by the media pool within amp-story-page:

But by not returning promise, we are not dispatching the VideoEvents.LOAD event:

The fact that the VideoEvents.LOAD event is not dispatched has nothing to do with the early return. The loadPromise will resolve no matter what, this is totally independent from the video.layoutCallback return value.

The issue is that the video element passed to the loadPromise will later be replaced by the media pool. When the media pool does this switch, it notifies the amp-video extension through the resetOnDomChange method:

https://github.com/ampproject/amphtml/blob/7e21559950ab9bf74650fd6d4ca02d6cc373685f/extensions/amp-video/0.1/amp-video.js#L610-L623

This method should start listening for load events and dispatch VideoEvents.LOAD when required. We should not spread the logic across different files, amp-video should keep handling all the video logic and events triggering.

All 11 comments

Is there anyone from @ampproject/wg-ui-and-a11y familiar with video analytics who can help us (@ampproject/wg-stories) debug this integration?

@nainar (as the facilitator of the UI and a11y working group), do you know what the next steps would be to get insights from someone in the team knowledgeable about video analytics?

Friendly ping to UI folks

@kristoferbaxter do you know who might be able to help us look into this? I think this will require understanding from both the stories and amp-video side, and want to make sure we're designing a solution correctly here.

@alanorozco @ampproject/wg-analytics

@micajuine-ho worked on this before. Do you mind taking a look? Thanks!

Yes, I can take a look at this :)

The issue is that the video-manager-impl is never receiving the VideoEvents.LOAD from amp-video, and so the video's analytics percentage tracker is never started.

We short circuit the video's layoutCallback (in amp-video), because we want it to be handled by the media pool within amp-story-page:

https://github.com/ampproject/amphtml/blob/44ea165c34f9cce37979f2849a88ca90016d568a/extensions/amp-video/0.1/amp-video.js#L374-L380

But by not returning promise, we are not dispatching the VideoEvents.LOAD event:
https://github.com/ampproject/amphtml/blob/44ea165c34f9cce37979f2849a88ca90016d568a/extensions/amp-video/0.1/amp-video.js#L357-L367

Off to @ampproject/wg-stories for a proper fix.

Thanks @micajuine-ho!

@mszylkowski if you have extra cycles coming up soon, can you investigate based on what Mica posted above?

Will assign it to @micajuine-ho as well to help on this.

From what I've seen, dispatchCustomEvent is being called for all the videos, but amp-analytics handleEvent does not get called for the events coming from the other pages

We short circuit the video's layoutCallback (in amp-video), because we want it to be handled by the media pool within amp-story-page:

But by not returning promise, we are not dispatching the VideoEvents.LOAD event:

The fact that the VideoEvents.LOAD event is not dispatched has nothing to do with the early return. The loadPromise will resolve no matter what, this is totally independent from the video.layoutCallback return value.

The issue is that the video element passed to the loadPromise will later be replaced by the media pool. When the media pool does this switch, it notifies the amp-video extension through the resetOnDomChange method:

https://github.com/ampproject/amphtml/blob/7e21559950ab9bf74650fd6d4ca02d6cc373685f/extensions/amp-video/0.1/amp-video.js#L610-L623

This method should start listening for load events and dispatch VideoEvents.LOAD when required. We should not spread the logic across different files, amp-video should keep handling all the video logic and events triggering.

Was this page helpful?
0 / 5 - 0 ratings