Want to track AMP page performance with Google Analytics 4 (GA4)? Here’s a quick guide to get started:
- Add AMP Analytics Script: Insert the required AMP script in your
<head>
section to enable tracking. - Configure GA4 Settings: Add your GA4 measurement ID in the AMP analytics JSON configuration to track pageviews and events.
- Enable AMP Linker: Ensure session continuity between AMP and non-AMP pages by setting up the AMP Linker with your domain.
- Monitor Key Metrics: Focus on metrics like pageviews, load time, engagement time, and bounce rate to evaluate performance.
- Handle Known Issues: Address session resets, limited GA4 features, and e-commerce tracking challenges with workarounds like custom parameters and AMP-specific solutions.
Quick Tip: Use a canonical tag to connect AMP and non-AMP pages for better data consolidation.
How to Implement Google Analytics on AMP Story
GA4 Setup for AMP Pages
Here’s a step-by-step guide to set up GA4 tracking for AMP pages.
Install AMP Analytics Code
First, add the base analytics script to your page:
<script async custom-element="amp-analytics"
src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
Place this script immediately after the AMP runtime script in your <head>
section. This ensures the analytics component loads properly.
Set Up AMP Analytics Settings
Next, configure the AMP analytics settings:
<amp-analytics type="gtag" data-credentials="include">
<script type="application/json">
{
"vars": {
"gtag_id": "G-XXXXXXXXXX",
"config": {
"G-XXXXXXXXXX": {
"groups": "default"
}
}
},
"triggers": {
"pageview": {
"on": "visible",
"request": "pageview"
}
}
}
</script>
</amp-analytics>
Replace G-XXXXXXXXXX
with your GA4 measurement ID. This setup will track pageviews and unlock additional event tracking features.
Configure AMP Linker
To maintain user tracking across AMP and non-AMP pages, enable AMP Linker:
"linkers": {
"enabled": true,
"proxyOnly": false,
"destinationDomains": ["yourdomain.com"]
}
Include this snippet within your amp-analytics JSON settings. Be sure to replace "yourdomain.com"
with your actual domain. This step ensures user sessions stay connected when moving between AMP and non-AMP pages.
After completing these steps, thoroughly test your implementation to confirm accurate data tracking and avoid any gaps.
Main Metrics for AMP Pages
GA4 provides critical data to help you assess the performance of your AMP pages and improve the user experience.
Page Performance Data
Keep an eye on these metrics to understand how your AMP pages are performing:
- Views by Page Title: Check which AMP pages attract the most traffic.
- Page Load Time: Measure and compare loading speeds of your AMP pages.
- First Visit: Track how new users engage with your AMP content.
- Page Referrer: Identify where your AMP traffic is coming from.
Here’s a quick overview of key performance metrics:
Metric | Description | Typical Range |
---|---|---|
Page Load Time | Time taken to fully load the page | 0.5–1.5 seconds |
First Contentful Paint | Time until the first content appears | 0.3–0.7 seconds |
Largest Contentful Paint | Time until the main content loads | 0.7–2.0 seconds |
Pair this data with user behavior metrics to gain a more complete understanding of your page performance.
User Behavior Data
Dive deeper into how users interact with your AMP pages by tracking:
- Engagement Time: Average time users actively interact with your content.
- Event Count: Total number of interactions during a session.
- Scroll Depth: How far users scroll down the page.
- Click Events: Identify which elements get the most clicks.
- Form Interactions: Monitor form completion rates on AMP pages.
Session Data
Session metrics give you a broader view of user engagement across your AMP pages:
- Session Duration: The average time users spend on your pages.
- Pages/Session: How many AMP pages a user views during a visit.
- Session Start: When users begin interacting with your content.
- Exit Rate: Percentage of users leaving from a specific AMP page.
- Bounce Rate: Percentage of single-page sessions.
To make the most of your tracking, focus on these session metrics:
Session Metric | What to Monitor | Why It Matters |
---|---|---|
Duration | Average time > 2 minutes | Indicates strong content engagement |
Pages/Session | 2+ pages viewed | Shows user interest in exploring |
Bounce Rate | < 65% for AMP pages | Reflects initial user engagement |
sbb-itb-880d5b6
AMP Analytics Setup Tips
To ensure accurate GA4 tracking, connect your AMP pages to their non-AMP versions using a canonical tag. Add the following code to the <head>
section of your AMP page:
<link rel="canonical" href="https://example.com/regular-page">
This setup helps consolidate user sessions across both versions of the page, allowing GA4 to properly track and combine user interactions.
Known Limits and Issues
GA4 tracking on AMP pages has technical constraints that require specific adjustments.
Limited GA4 Features
When it comes to AMP pages, GA4 offers fewer features compared to standard web pages. Here are some major limitations:
- Google Signals Integration: AMP pages don’t support Google Signals, which restricts cross-device tracking and access to demographic insights.
- Enhanced Measurement: Features like automatic scroll tracking and file download tracking aren’t available on AMP pages.
- Custom JavaScript: AMP’s strict framework blocks the use of custom JavaScript, making advanced tracking setups impossible.
To work around these issues, stick to basic event tracking using AMP’s built-in analytics and URL parameters for gathering extra data. Let’s now look at the hurdles specific to e-commerce tracking on AMP pages.
E-Commerce Tracking Limits
Tracking e-commerce activity on AMP pages comes with its own set of challenges:
- Product List Views: Standard tracking for e-commerce lists isn’t supported, so you’ll need to configure events manually.
- Cart Interactions: Real-time tracking of cart updates is unavailable, requiring custom AMP events for cart actions.
- Transaction Data: Purchase tracking relies on simplified data structures, unlike the detailed options available in standard GA4 setups.
Here’s an example of a basic purchase tracking setup using AMP’s amp-analytics
component:
<amp-analytics type="gtag" config="https://www.googletagmanager.com/amp.json?id=GA4-MEASUREMENT-ID">
<script type="application/json">
{
"vars": {
"transaction_id": "ORDER123",
"value": 99.99,
"currency": "USD"
}
}
</script>
</amp-analytics>
Next, let’s address session continuity concerns that often arise on AMP pages.
Session Reset Problems
Session tracking on AMP pages can encounter disruptions due to:
- Cross-Domain Issues: Sessions may reset when users switch between AMP and non-AMP versions of your site.
- Cache Interference: The Google AMP Cache can interfere with session attribution.
- Referral Data Loss: Original referral data may be lost when users transition from AMP to non-AMP pages.
You can reduce these problems by taking the following steps:
- Set Up AMP Linker: Ensure the AMP linker is configured properly to maintain session continuity across domains.
- Use Custom Session Parameters: Add custom parameters to track user journeys when they move between AMP and non-AMP pages.
- Monitor Session Data: Regularly review session patterns to identify and address anomalies in tracking.
These solutions can help maintain accurate data collection and user tracking despite AMP-related constraints.
Conclusion
Setting up GA4 to track AMP pages requires careful configuration and an understanding of its limitations. While AMP has its challenges, using GA4 effectively can provide meaningful insights to guide your decisions.
For businesses aiming to improve their setup, seeking expert assistance can be a smart move. As SearchX puts it:
"You’re not paying for a checklist of tasks; you’re paying for outcomes. We’re relentless in our pursuit of success and adjust strategies based on what’s getting you results – whether that’s new tactics, shifting focus, or doubling down on winning strategies." [1]
Accurate data and a focus on the right metrics are key to making the most of AMP tracking and improving performance.