Launch Event Only Once Every 60 Seconds (JavaScript)
<p>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.</p>

<p>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.</p>

<p><strong>The problem is when it comes to time.</strong> 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.</p>

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

<pre><code>&lt;script type="text/javascript"&gt;
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 &lt; following.length; ++t )
    {
        var Follow = following[t];
        if ( gone &gt;= Follow.min &amp;&amp; gone &lt; Follow.max )
        {
             if ( ! Follow.done )
             {
                 var range = Follow.min + " Seconds Watched ";
                 _gaq.push(['_trackEvent', range, 'Play', 'Title']);
                 Follow.done = true; 
             }
             break;
        }
    }
}
);
&lt;/script&gt;
</code></pre>
