googleanalytics / autotrack

Automatic and enhanced Google Analytics tracking for common user interactions on the web.
Other
4.92k stars 560 forks source link

Feature request: impressionTracker track after X seconds of visibility #244

Open shocknawe opened 5 years ago

shocknawe commented 5 years ago

Feature request: impressionTracker tracking after X seconds of element visibility

It would be nice to know if the user has spent enough time within the element to read it before tracking it as an impression. I was thinking the user needs somewhere around 2-3 seconds to properly be 'impressed' by an element

sample use case:

// JAVASCRIPT
ga('impressionTracker:observeElements', ['product-description']);

// HTML
<div id="product-description"
  data-ga-event-min-duration="3000"
  data-ga-event-category="Product Page"
  data-ga-event-action="Read Product Description"
  data-ga-event-label="Fender FA-345CE Auditorium Acoustic Guitar, Tea Burst">
  <p>An instrument that sounds as good as it looks ...</p>
</div>

sample element visibility duration tracking: https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API/Timing_element_visibility#Result

image screenshot of 15 seconds of impression