New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[amp-analytics] Use IntersectionObserver to do visibility tracking #5697

lannka opened this Issue Oct 19, 2016 · 1 comment


None yet
3 participants

lannka commented Oct 19, 2016

Comparing to the current scroll-event based approach, native IntersectionObserver provides the following benefit:

  • More performant. The current approach invokes calculation on every scroll event. InOb only invokes calculation when intersect boundary has been crossed.
  • More accurate visibility tracking. Because the current approach doesn't take DOM mutation into consideration, hence is not accurate. InOb will take care of it.
  • Work inside xorigin iframe, such as the case of amp-inabox (#5700), where we can't use the current scroll-event based approach.

Note: IntersectionObserver only fires when the intersection is crossing a list of pre-specified thresholds, hence we will not have exact value for metrics minVisiblePercentage and maxVisiblePercentage. We decided to approximate the values using thresholds of [0, 0.05, 0.1, ..., 1]. See discussion here: #5942

@avimehta @cramforce


This comment has been minimized.

Show comment
Hide comment

lannka Dec 28, 2016


Further clean up work is tracked separately in #6828


lannka commented Dec 28, 2016

Further clean up work is tracked separately in #6828

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment