amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

amp-next-page event in google analytics triggers too early

Open Salisteeg opened this issue 5 years ago • 3 comments

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>

Salisteeg avatar Mar 22 '21 00:03 Salisteeg

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?

dmanek avatar Mar 24 '21 21:03 dmanek

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

Salisteeg avatar Mar 26 '21 12:03 Salisteeg

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.

dmanek avatar Apr 12 '21 21:04 dmanek