title: Time Spent by user on a web page + Iframe
body: <p>I want to measure the time spent by a user on web pages. It's doesn't include the time when a user navigates away from the browser.</p>
  
  <p>I found few open source libraries like <a href="https://github.com/jasonzissman/TimeMe.js/" rel="noreferrer">Timejs</a> library which can measure the time spent by a user on a web page, but when a user is watching a Youtube video on the page, these libraries don't measure that time.</p>
  
  <p>.</p>
  
  <ol>
  <li>Is there a way to handle this case or any other library which handles this case?</li>
  <li>Actually, these libraries fail to calculate the time spent by the user inside an iFrame.What is the best way to know when a user is active in an IFrame? </li>
  <li>How does Google/AppNexus/Motomo calculate interaction time? Is there a common design/architecture that they follow?</li>
  </ol>
  
  <p>PS: I am trying to integrate the library with my react App. If there exists any similar method to solve this problem in React. Please let me know in comments/answers.</p>
  
  <p>Thanks in advance </p>