• Resolved junpeizaki

    (@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 9 replies - 1 through 9 (of 9 total)
  • Thread Starter junpeizaki

    (@junpeizaki)

    You can also recreate the issue using Chrome Inspect Element > Simulate Mobile Device > Open this Gppgle AMP Search Result link: https://www.google.com/amp/s/edamame.reviews/pineapple-pen-ketchapp-review/%3famp

    Plugin Contributor Pierre Gordon

    (@pierlo)

    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.

    Thread Starter junpeizaki

    (@junpeizaki)

    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 https://edamame.reviews/taxi-rush-review/?amp

    It does not, however, track impressions for content that is cached on Google’s servers. For example https://www.google.com/amp/s/edamame.reviews/pineapple-pen-ketchapp-review/%3famp

    I hope this makes more sense.

    • This reply was modified 5 years ago by junpeizaki.
    Thread Starter junpeizaki

    (@junpeizaki)

    Any suggestions anyone?

    Plugin Contributor Alain Schlesser

    (@schlessera)

    @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: https://developers.google.com/amp/cache/update-cache

    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: https://cdn.ampproject.org/caches.json

    Thread Starter junpeizaki

    (@junpeizaki)

    @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

    (@westonruter)

    Note that https://www.google.com/amp/s/edamame.reviews/pineapple-pen-ketchapp-review/%3famp 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: https://edamame-reviews.cdn.ampproject.org/c/s/edamame.reviews/taxi-rush-review/?amp

    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: https://support.google.com/analytics/answer/6343176

    You can also reach out to a general AMP support channel: https://amp.dev/support/

    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.

    Thread Starter junpeizaki

    (@junpeizaki)

    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.

    Hi,
    Im having same issue…. how can I check the max-age on my caching header is set to?
    Also im working with ezoic nameserver integration, so maybe them have other cache headers…
    Regards

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘AMP views from Google not showing in Google Analytics’ is closed to new replies.