GA4 AMP analytics integration relies on the tag configured with the googleanalytics type. You define pageview measurements and custom event triggers directly inside a JSON configuration block embedded in your AMP HTML template. This architecture allows AMP pages to dispatch data directly to Google Analytics 4 endpoints while strictly adhering to AMP validation rules and preserving fast mobile loading performance.
Why is tracking custom events on AMP pages different from standard websites?
Standard web pages usually execute Google Tag Manager or the standard gtag.js library to handle tracking. These scripts execute custom JavaScript to listen for DOM events, build payloads, and send requests. However, the AMP framework prohibits arbitrary custom JavaScript to preserve strict rendering budgets and minimize CPU work on mobile processors.

Instead of executing custom scripts, AMP uses a declarative framework. You specify tracking rules inside a structured JSON object within the element. The underlying AMP runtime interprets this JSON markup, attaches event listeners to target DOM elements, and formats network requests to GA4 endpoints. Capturing a custom event like a call-to-action click or a scroll threshold requires writing valid JSON configuration rather than adding inline JavaScript handlers.
- AMP Runtime Scripts: The tag must reside in the page HTML head.
- Measurement ID: A valid GA4 Measurement ID starting with G- is required in the configuration object vars.
- JSON Schema: The configuration payload must follow strict JSON syntax without unescaped quotes or trailing commas.
- Trigger Selectors: Element IDs or CSS classes referenced in click triggers must exist in the body markup.
- Transport Options: Using beacon or image transport ensures analytics requests complete even during rapid navigation.
How do you set up basic GA4 measurement inside the amp-analytics tag?
To begin tracking, place the amp-analytics component within the body of your AMP document. Specify type=”googleanalytics” as an attribute on the component tag. Inside a child tag, declare your configuration. You must define a vars dictionary that contains your target ga_measurement_id. Automatic pageview tracking triggers immediately when the AMP runtime initializes the component on user load.
The base configuration handles general traffic metrics, such as page location, referrer details, and screen resolution. Because AMP pages run in restricted sandboxes or inside AMP caches, client identifiers are automatically managed by the runtime. This ensures that session continuity remains intact when users transition from cache URLs to origin domains.

Google treats responsive web pages and AMP pages equally in search indexation and evaluation.
Google Search Central
How to trigger custom events on AMP button clicks and form submissions?
Custom event tracking in AMP requires adding objects to the triggers block of your JSON setup. Every trigger entry contains a trigger name, an on property specifying the interaction type, a selector targeting the specific element, and a request type. For example, to track a click on a lead form button, set on to click and selector to #submit-btn.
Next, map the trigger to an event request. Within the vars object of that specific trigger, specify event_name alongside any custom parameter names you want to pass to GA4. When a user taps the targeted element, the AMP runtime constructs an HTTP request matching the GA4 Measurement Protocol structure and sends it in the background without interrupting user navigation.
- Identify Target Elements: Locate specific CSS class names or element IDs for tracked buttons, forms, or links.
- Define Event Names: Choose standard or custom event names like generate_lead or select_content that align with your reporting structure.
- Construct JSON Triggers: Add a dedicated entry within the triggers block using the chosen element selector.
- Pass Event Parameters: Include custom attributes like button_location or form_id under the trigger variable block.
- Test Event Firing: Inspect network requests in browser developer tools to verify that events send payload data correctly.
What are the common custom event parameters used in AMP tracking?
When sending events to GA4, passing contextual metadata helps break down user interactions during reporting. Standard parameters include page title, page path, and section categories. In AMP JSON configurations, you can pull dynamic values using built-in AMP variable expansion, such as ${title}, ${canonicalPath}, or ${documentReferrer}.
For custom events, you can pass custom parameters under the vars object inside each trigger definition. For instance, tracking a video play button can pass video_title and video_provider as custom keys. GA4 registers these keys when mapped as custom dimensions in the Google Analytics interface, giving your team rich insights into mobile engagement without custom JavaScript execution.
How Alien Road applies GA4 analytics in AMP
At Alien Road, our team integrates custom analytics tracking into AMP templates through a systematic deployment workflow for client projects. In a typical engagement, we begin by auditing existing desktop tag configurations to map required event dimensions directly to AMP JSON schemas. This ensures that key metrics match across standard responsive pages and mobile AMP variants without creating reporting discrepancies.
During the implementation phase, we construct custom JSON templates that capture critical conversion milestones, including contact form submissions, phone link taps, and outbound clicks. We implement transport beacon parameters to prevent data loss on high-velocity user journeys. Once published, our technical team conducts verification across live mobile browsers and AMP cache URLs to ensure that events fire predictably under varying network conditions.
Finally, we set up real-time monitoring dashboards within GA4 to confirm that incoming custom events correctly populate standard exploration reports. By maintaining strict schema validation routines, we prevent tracking regressions when client engineering teams update site templates or introduce new marketing campaigns over time.
Google Search indexes AMP pages just like other web pages, and applies the same standard to all pages, regardless of the technology used to build the page.
Google Search Central
How to verify and debug custom GA4 events in AMP validation tools?
Validating your analytics configuration is a critical step before deploying AMP pages to production. Invalid JSON syntax inside the block breaks the component and prevents tracking requests from firing entirely. Furthermore, syntax errors cause the page to fail AMP validation, which can remove the page from Google AMP Cache distribution.
To debug issues, append #development=1 to your local AMP page URL and open browser developer tools. The browser console displays detailed log entries from the AMP runtime, showing whether the amp-analytics extension loaded and listing each trigger evaluated. You can also inspect the Network tab to monitor outgoing network calls directed to google-analytics.com/g/collect and review parameters like en for event name and ep.* for event parameters.
Where to start this week with your mobile measurement
Begin your optimization work by auditing your top-performing mobile AMP pages using browser developer tools. Verify that the dependency is properly included in the document head and that your current ga_measurement_id value matches your active GA4 property.
Next, pick one key user action on your site, such as a primary conversion button, and add a simple click trigger to your JSON configuration. Deploy the change to a test environment, trigger the action manually, and check GA4 DebugView to confirm event delivery. Once verified, expand the JSON markup to cover remaining business goals across your template library.