amp-next-page event in google analytics triggers too early
After updating the amp-next-page library to version 1.0, the infinite scroll event in analytics began to be called at the slightest scroll on the page. Example page: https://www.gestacaobebe.com.br/amp/importancia-do-zinco-para-gestante-e-o-bebe Video: https://clickio.gyazo.com/e6c265f16af473ee89c5b64422b91d7f All browsers affected. amp-analytics config:
<script type="application/json">
{
"requests": {
"clickioPageview": "${pageview}&ds=${ds}",
"nextpage": "${event}&ea=infscroll_down&ec=navigation&ds=${ds}"
},
"vars": {
"account": "UA-37902563-1",
"ds": "clickio_dynamp"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "clickioPageview"
},
"trackPageviewScrollThrough": {
"on": "amp-next-page-scroll",
"scrollSpec": {
"useInitialPageSize": true
},
"request": "clickioPageview"
},
"trackScrollThrough": {
"on": "amp-next-page-scroll",
"scrollSpec": {
"useInitialPageSize": true
},
"request": "nextpage"
}
}
}
</script>
Hey @Salisteeg, thanks for reporting this issue. To clarify, you mean that amp-next-page triggers an analytics event when the page loads or on slight scroll correct? The following amp-next-page-scroll events when user scrolls are working as expected?
Yes, the problem is that amp-next-page-scroll event for the first page is triggered immediately after scroll, all other amp-next-page-scroll events for following pages work correctly
Fixing this issue will change when amp-next-page-scroll event fires and break sites relying on this event. For this reason, I'm going to be talking about it in design review on Apr 14th (see #33451) to make sure we don't break anyone.