Support » Plugin: AMP » AMP views from Google not showing in Google Analytics

  • Resolved junpeizaki


    Hi guys,

    Impressions of my AMP pages via Google aren’t showing up in my Google Analytics.

    i.e. The AMP version of my site served to users accessing my site via Google Search Results are not tracked in Google Analytics. After examining the page sauce you will see that no Google Analitycs tracking code is included in the page served to users via Google Search Results.

    This can be tested using Google Chrome’s Inspect Element tool to simulate a mobile device > search “pinapple pen game review” which is a keyowrd I currently have the top search result for > view page sauce.

    My Google Analytics set up in the “Analytics” section of AMP plugin.

    Type: googleanalytics
    ID: d1d862cba312

        "vars": {
            "gtag_id": "UA-103155551-3",
            "config": {
                "UA-103155551-3": {
                    "groups": "default"

    Does anyone have any suggestions as to why this may be happening?
    Thank you for any help you can give.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • You can also recreate the issue using Chrome Inspect Element > Simulate Mobile Device > Open this Gppgle AMP Search Result link:

    Plugin Support Pierre Gordon


    Some posts on your site are being served as AMP and do include your Google Analytics tracking code (such as this one). The reason why some pages don’t include it, however, could be because of invalid markup being included on those pages, making them AMP incompatible.

    When the plugin detects these invalid markup, they are stripped from the page to allow it to be served as AMP. If the invalid markup is kept, then URLs it occurs on will not be served as AMP pages.

    Visiting the AMP Validated URLs page in your admin console will give you more detailed information on this.

    I understand what you are saying, but don’t fully understand how this would prevent Google Analytics from tracking impressions to my site. I added the tracking code within the Analytics section of the official AMP plugin, following the instructions shown here.

    Why would AMP strip code that has obviously been formatted for AMP pages?

    To clarify, Google Analytics does track impressions for my AMP pages with the URL’s ending in “/?amp” for example

    It does not, however, track impressions for content that is cached on Google’s servers. For example

    I hope this makes more sense.

    • This reply was modified 2 months, 1 week ago by junpeizaki.

    Any suggestions anyone?

    Plugin Support Alain Schlesser


    @junpeizaki It looks like the Google AMP Cache has cached a non-AMP version of your “Pineapple Pen” page. As the Google Analytics script is a regular JS snippet on the non-AMP page, it will not get executed and not track the page view.

    I suppose the cache might have been generated at a time when the page itself was invalid and redirected to its non-AMP version.

    This might solve itself after cache expiration. I wanted to check what the max-age on your caching header is set to, but right now the cache seems to be forcefully disabled. Maybe this is because you were already trying to force a refresh.

    You can manually invalidate the page from the Google AMP Cache using the following procedure:

    Keep in mind that the Google AMP Cache is not the only one. You can see the list of officially known AMP caches by reading the following URL:

    @schlessera Thanks for the reply and suggestions.

    Your suggestion is very plausible and is kind of the conclusion I came to after testing many many different options.

    One thing I would like to point out is that the cached version as far as I can tell is, in fact, the valid AMP version of my site. As I am sure you are probably well aware, I am using Twenty Twenty which is an AMP-compatible theme meaning the look and feel of the site should stay cohesive between AMP and non-AMP versions of my site.

    What I am worried about is if Google is stripping the tracking code I implemented within the Analytics sections of the AMP plugin when it caches AMP versions of my page on its servers.

    I tried cleating the page in question’s cache using the method you described but to no avail. Considering the page I used as an example isn’t only that page that seems to be affected – I don’t think I am currently able to track any mobile traffic coming from Google via AMP, I thought this could potentially be a much greater problem.

    Thanks for all the help.

    Plugin Author Weston Ruter


    Note that is the URL to the Google AMP viewer. If you try accessing that URL with a desktop user agent, it will redirect to the canonical URL. So to view the AMP viewer, you have to emulate a mobile user agent.

    The AMP viewer contains an iframe pointing to the AMP cache.

    I can see that URL contains amp-analytics:

    <amp-analytics class="i-amphtml-layout-fixed i-amphtml-layout-size-defined" i-amphtml-layout=fixed id=d1d862cba312 style=width:1px;height:1px; type=googleanalytics><script type=application/json>{"vars":{"account":"UA-103155551-3"},"triggers":{"trackPageview":{"on":"visible","request":"pageview"}}}</script></amp-analytics>

    Refer also to this non-viewer AMP Cache URL:

    It also has <amp-analytics>. So I don’t see anything being stripped.

    We’re not necessarily experts on Google Analytics. I suggest referring to Google Analytics support for assistance:

    You can also reach out to a general AMP support channel:

    This support forum is specifically about getting WordPress to generate valid AMP pages. To get support with specific AMP components, like amp-analytics, it is best to reach out to another channel.

    Hi, thanks for all of the support.

    It seems it was just a matter of Google updating the pages it had cached – which is probably why you were able to find the analytics tag since it updated overnight.

    Hopefully, anyone else having a similar problem can benefit from my struggles.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.