How to track AMP

This is the script that you can customized in order to track AMP (Accelerated Mobile Pages) pageviews. Make sure to edit the code pushing the correct variables if you use a custom CMS, or use the Wordpress code if you run Wordpress (e.g. substitute TITLE, SOURCE_URL and similar values with the correct values). Put this code before the end of the .

<amp-analytics>
    <script type="application/json">
        {
            "requests": {
                "event": "https://api.publytics.net/events"
            },
            "extraUrlParams": {
                "r": "${documentReferrer}",
                "u": "SOURCE_URL",
                "w": 400,
                "d": "example.com/EXMPL1"
            },
            "triggers": {
                "trackPageview": {
                    "on": "visible",
                    "request": "event",
                    "extraUrlParams": {
                        "n": "pageview",
                        "p": {
                                "amp":true,
                                "article_title": "TITLE"
                             }
                    }
                },
                "trackScrollThrough":{
                    "on":"amp-next-page-scroll",
                    "useInitialPageSize": true,
                    "request":"event",
                    "extraUrlParams": {
                      "n": "amp_next_page_pageview"
                    }
                },
                "trackClickThrough":{
                    "on":"amp-next-page-click",
                    "useInitialPageSize": true,
                    "request":"event",
                    "extraUrlParams": {
                      "n": "amp_next_page_pageview"
                    }
                }
            },
            "transport": {
                "beacon": true,
                "xhrpost": true,
                "image": false,
                "useBody": true
            }
        }
    </script>
</amp-analytics>

AMP - Next Page Plugin

This is the script to be customized in order to track AMP (Accelerated Mobile Pages) next-page pageviews (if you use that specific plugin). Make sure to edit the code pushing the correct variables if you use a custom CMS, or use the Wordpress code if you run Wordpress.

<amp-analytics>
    <script type="application/json">
        {
            "requests": {
                "event": "https://api.publytics.net/events"
            },
            "extraUrlParams": {
                "r": "${documentReferrer}",
                "u": "SOURCE_URL",
                "w": 400,
                "d": "example.com/EXMPL1"
            },
            "triggers": {
                "trackPageview": {
                    "on": "visible",
                    "request": "event",
                    "extraUrlParams": {
                        "n": "pageview",
                        "p": {
                                "amp":true,
                                "article_title": "TITLE"
                             }
                    }
                },
                "trackScrollThrough":{
                    "on":"amp-next-page-scroll",
                    "useInitialPageSize": true,
                    "request":"event",
                    "extraUrlParams": {
                      "n": "amp_next_page_pageview"
                    }
                },
                "trackClickThrough":{
                    "on":"amp-next-page-click",
                    "useInitialPageSize": true,
                    "request":"event",
                    "extraUrlParams": {
                      "n": "amp_next_page_pageview"
                    }
                }
            },
            "transport": {
                "beacon": true,
                "xhrpost": true,
                "image": false,
                "useBody": true
            }
        }
    </script>
</amp-analytics>