Skip to content

sendbeacon "percentsPlayedInterval" instead of "percent" #32

@Barri-G

Description

@Barri-G

Hi.

As a videojs user now I need to get some information about "percent played" on some of my websites.

I've tried your code and it works, but I think the way it sends the percent played is not the easiest way to understand the information; I mean, when somebody plays 10% I get 10 as a value on my analytics. But if the video continues playing and reach 20% then "percent" = 20 is sent, so analytics shows "30" (10+20). I think the script should send 10 always if "percentplayedinterval" is set to 10. I was thinking about changing this piece of code

  for percent in [0..99] by percentsPlayedInterval
      if percentPlayed >= percent && percent not in percentsAlreadyTracked

        if "start" in eventsToTrack && percent == 0 && percentPlayed > 0
          sendbeacon( 'start', true )
        else if "percentsPlayed" in eventsToTrack && percentPlayed != 0
          sendbeacon( 'percent played', true, percent)

to this:

  for percent in [0..99] by percentsPlayedInterval
      if percentPlayed >= percent && percent not in percentsAlreadyTracked

        if "start" in eventsToTrack && percent == 0 && percentPlayed > 0
          sendbeacon( 'start', true )
        else if "percentsPlayed" in eventsToTrack && percentPlayed != 0
          sendbeacon( 'percent played', true, percentsPlayedInterval)

but before doing it I'd like to know if I'm omitting anything important, because you chase to use "percent" instead of "percentsPlayedInterval" on "sendbeacon" and probably you have your reasons.

Thank you for your time and your great project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions