How to track AMP Pages with Google Analytics 4

How to track AMP Pages with Google Analytics 4

How to track AMP Pages with Google Analytics 4.webp


Google Analytics for AMP
AMP Analytics Config for Tracking AMP Pages using Google Analytics 4. This repository let you add a configuration file to your AMP setup in order to track.


Just add the following code to your AMP Pages:
HTML:
<amp-analytics type="googleanalytics" config="https://reverb.vn/ga4.json" data-credentials="include">
<script type="application/json">
{
    "vars": {
                "GA4_MEASUREMENT_ID": "G-XXXXXXXX",
                "GA4_ENDPOINT_HOSTNAME": "www.google-analytics.com",
                "DEFAULT_PAGEVIEW_ENABLED": true,
                "GOOGLE_CONSENT_ENABLED": false,
                "WEBVITALS_TRACKING": false,
                "PERFORMANCE_TIMING_TRACKING": false
    }
}
</script>
</amp-analytics>

Feature NameDescription
GA4_MEASUREMENT_IDYour Measurement ID, Replace “G-XXXXXXXX” with your GA4 measurement ID
GA4_ENDPOINT_HOSTNAMEOverride the default endpoint domain. In case you want to send the hits to your own server or a Server Side GTM Instance.
GOOGLE_CONSENT_ENABLEDa &gcs parameter will be added to the payloads with the current Consent Status
WEBVITALS_TRACKINGIf you enable this a webvitals event will fire 5 seconds after the page is visible
PERFORMANCE_TIMING_TRACKINGWhatever you want to push a performance_timing event including the current page load performance timings
DEFAULT_PAGEVIEW_ENABLEDIf enabled a page_view event will fire on the page load
SEND_DOUBLECLICK_BEACONSend a DC Hit
ga4.jsonDownload and upload ga4.json to your server, replace "reverb.vn/ga4.json" with "your-domain/ga4.json"

How to track AMP Pages with Google Analytics 4.webp


Source:
thyngster.com
 

Attachments

Last edited:
Top