AMP pages cannot run normal JavaScript, so PubPulse receives their pageviews through amp-analytics.

Code

Add the amp-analytics script in the head and this block in the body. Use the same d value (domain/ID) as your normal pages. The exact block for your site, with your ID filled in, is in Settings → Tracking Code → AMP.

<amp-analytics>
    <script type="application/json">
        {
            "requests": { "event": "https://pubpulse.pro/api/event" },
            "extraUrlParams": { "r": "${documentReferrer}", "u": "${canonicalUrl}", "w": 400, "d": "yourdomain.com/SITE_ID" },
            "triggers": { "trackPageview": { "on": "visible", "request": "event", "vars": { "n": "pageview" } } },
            "transport": { "beacon": true, "xhrpost": true, "useBody": true, "image": false }
        }
    </script>
</amp-analytics>

Parameters

ParameterMeaning
nevent name, pageview for a page
upage URL
rreferrer
ddomain/ID; several separated by commas
pproperties (custom dimensions) as JSON

Try PubPulse free for 30 days

Every feature, no pageview limit, no credit card. Paste one line of code and your first visits show up within seconds.

Start your free trial

or click around the live demo first, no sign-up needed