Setting Up Cross-Domain Tracking for AMP and Non-AMP Pages

AMP cross-domain tracking in GA4 requires a coordinated configuration between your AMP cache pages and your canonical non-AMP site. By using the amp-analytics component, you pass client IDs across domains to maintain a single user session. This process ensures that when a visitor moves from an AMP page hosted on the Google AMP Cache to your primary domain, their session remains intact for accurate conversion measurement. Without this, your analytics account sees the transition as two separate users, which inflates your bounce rate and distorts your user acquisition data.

The implementation relies on the ‘linker’ parameter, which carries the identification data through the URL query string. When a user clicks a link from your AMP page to your main domain, the browser appends this data to the URL. If the receiving site is properly configured, it extracts this information and continues the session. This is standard practice for maintaining continuity in modern web environments.

Setting Up Cross-Domain Tracking for AMP and Non-AMP Pages

How does cross-domain tracking work in GA4?

Cross-domain tracking functions by linking a specific client ID across different domains. In a standard setup, a cookie stores the client ID on your primary domain. When a user navigates to a new domain, that cookie cannot be read due to browser security policies. GA4 handles this by appending a linker parameter to the URL, which allows the destination page to capture and adopt the existing client ID.

Consider a user reading an article on an AMP cache site who then clicks a link to your main store. If the linker parameter is missing, the browser cannot bridge the gap between the two domains. The GA4 measurement protocol effectively sees two distinct visits. By configuring the linker, the URL query string includes a _gl parameter that contains the necessary identification data to stitch the session back together.

This mechanism is essential for sites that rely on high-traffic AMP articles to drive users to conversion-focused landing pages. Without this configuration, your attribution reports will fail to credit the AMP entry point for sales made on the canonical site. Implementing this correctly provides a clear view of how your content strategy impacts your bottom line.

Setting Up Cross-Domain Tracking for AMP and Non-AMP Pages — 2

What is the technical requirement for AMP pages?

AMP pages are often served from a cache domain, which is distinct from your own. To track users correctly, the amp-analytics component must be configured to share the client ID. You must define the linker configuration within your AMP HTML code to ensure the necessary parameters are passed during user navigation.

This configuration is handled within the JSON object inside the amp-analytics tag. You need to specify the domains that should receive the linker parameter. Failure to include your canonical domain in this list will result in the parameter being stripped or ignored, causing the session to reset upon landing on your site.

You should also ensure that your canonical site is prepared to accept these parameters. If your canonical site has strict URL cleaning or redirect rules, they might remove the _gl parameter before GA4 can process it. Always test your redirects to confirm the parameter remains intact throughout the transition from the cache domain.

Essential steps for implementation

  • Include the amp-analytics script in the head section of your AMP document.
  • Configure the linker parameter within the analytics JSON configuration.
  • Specify your canonical domain in the ‘domains’ array to enable parameter passing.
  • Ensure your canonical site is also configured to accept the incoming linker parameter via GA4 settings.
  • Test the setup using the Google Tag Assistant to verify that the client ID persists across domains.

How Alien Road applies this

At Alien Road, our team approaches cross-domain projects by first auditing the existing tag architecture. We verify that all canonical pages use a consistent GA4 measurement ID before modifying the AMP components. For a typical engagement, we deploy the configuration through our tag management framework, ensuring that the linker parameters are correctly formatted for both the AMP cache and the target domain.

We then perform a series of navigation tests to confirm that session stitching occurs as expected. If the ID resets, we check for potential conflicts with other scripts or sub-domain settings. This systematic verification ensures that our reports reflect true user journeys rather than fragmented data points. Our process includes verifying the _gl parameter in the browser’s address bar during the transition phase.

In our workflow, we often find that legacy redirects or outdated URL parameters interfere with GA4 tracking. We clean up these configurations to ensure a direct path for the linker object. After deployment, we monitor the ‘Session Source/Medium’ report for a few days to ensure that the AMP traffic is correctly attributed to the canonical site rather than appearing as direct or referral traffic.

Common troubleshooting steps

If you notice session drops, verify your tag settings first. Often, the issue lies in the configuration of the allow-linker attribute. Ensure that your setup adheres to official standards for data collection. Another frequent issue is mismatched GA4 Measurement IDs between the AMP page and the canonical page, which prevents the session from being shared properly.

Checking for potential interference from other tracking pixels is also essential. Sometimes, third-party scripts modify URL parameters, which can break the linker string. Always monitor your browser console for errors related to the amp-analytics component during the redirect process.

Use the AMP Test Tool to ensure that your AMP content is valid.

Google Search Central

How to verify your data integrity?

Validation is the final stage of any tracking project. You should monitor your reports for anomalies in acquisition channels and session duration. Consistency in data reporting indicates that your cross-domain logic is functioning. You must ensure that the transition between domains does not create high bounce rates caused by session fragmentation.

Regularly check the referral exclusion list in your GA4 settings. If your canonical domain is not listed there, or if your AMP cache domain is missing, GA4 might create new sessions when a user moves between them. Keeping this list updated is a key maintenance task for any site using AMP.

  • Check the GA4 Real-time report while clicking through from an AMP page to your main site.
  • Compare the client ID values in the browser console across both domains to confirm they match.
  • Review the referral exclusion list in GA4 settings to prevent self-referral issues.
  • Monitor the AMP status report in Search Console to catch indexing errors.

Where to start this week

Begin by auditing your current AMP HTML implementation to see if the amp-analytics component is present. Once confirmed, draft a list of all domains involved in your user journey. Apply the linker configuration to your test environment first before pushing changes to your live site, and verify the flow using browser developer tools to see the URL parameters in action.

Schedule a review of your GA4 referral exclusions. If you identify gaps in your data, create a test case where you simulate a user journey from the cache domain to your main site. Documenting these steps will help your team maintain consistent tracking as your site grows and changes over time.

Share