Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8100763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:49:57+00:00 2026-06-05T22:49:57+00:00

I have a video that is 60 seconds long. I am working on adding

  • 0

I have a video that is 60 seconds long. I am working on adding some JavaScript to send data from my video player to Google Analytics. What I am looking to do is to launch an event no more than once every 60 seconds for a range of time.

So for example, a user watches 21 to 40 seconds into a video, I want only one event launched (rather then 19 times for the 19 seconds of time). Then the user watches 41 to 60 seconds into the video, I want only one event launched. I actually have figured this part out already.

The problem is when it comes to time. So if a user watches the 21 to 40 seconds it launches an event. They watch the rest of the video and mentally process it and decide “hey I want to watch the video again”. If they watch the video again, that one event at 21 to 40 seconds won’t launch again unless they refresh the page.

How can I edit my script so an event is launched only once every 60 seconds for a specific range?

<script type="text/javascript">
function Follow( minimum, maximum )
{
this.min = minimum;
this.max = maximum;
this.done = false;
}
var following = [
new Follow( 1, 20 ),
new Follow( 21, 40 ),
new Follow( 41, 60 )
]; 

player().Time(
function(event) 
{
    var gone = Number(event.secondspassed);
    for ( var t = 0; t < following.length; ++t )
    {
        var Follow = following[t];
        if ( gone >= Follow.min && gone < Follow.max )
        {
             if ( ! Follow.done )
             {
                 var range = Follow.min + " Seconds Watched ";
                 _gaq.push(['_trackEvent', range, 'Play', 'Title']);
                 Follow.done = true; 
             }
             break;
        }
    }
}
);
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:49:58+00:00Added an answer on June 5, 2026 at 10:49 pm

    You can add this.last to your Follow objects and record the time that that Follow was last fired.

    function Follow( minimum, maximum ){
        this.min = minimum;
        this.max = maximum;
        this.done = false;
        this.last = 0;
    }
    

    Then in your function you can check if it’s been over a minute since it last fired:

    var Follow = following[t];
    if((new Date).getTime() > Follow.last + 60000)
        Follow.done = false;
    

    And finally when you set Follow.done to true, also set the last time it fired to the current time:

    Follow.done = true; 
    Follow.last = (new Date).getTime();
    

    The code above does what you asked for, but I’m not sure how well this will deal with pausing and continuing the video over a minute later. It will probably also fire the event twice in that situation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that will stream video from a camera at 720p and
I have some video that I would like to convert to images of frames
I have found that the default video buffer size was set to 8 seconds
I have a function that gets a video item from youtube, below is the
I have a Video Chat application that I want to disconnect from a call
I have some task in my script that is about converting video with ffmpeg
I have a jQuery function that updates my data ever few seconds. But! It's
I have a huge list of video files from a webcam that have that
I have a video that plays in portrait mode. At the end of the
I have a requirement where i have a Video that is played using MPMediaPlayerController

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.