• Resolved devitaliza

    (@devitaliza)


    Hello,

    I have been trying to read through the AMP documentation from Google. However, it’s a bit over my head.

    I have two questions:

    Firstly, does the analytics code also work for pages served by the Google cache? The code I am using is the code provided by the AMP plugin:

    {
    “vars”: {
    “account”: “UA-XXXXX-Y”
    },
    “triggers”: {
    “trackPageview”: {
    “on”: “visible”,
    “request”: “pageview”
    }
    }
    }

    Secondly, what is the difference between how the above code works and how the code provided on the developers.google page works?

    {
    “vars” : {
    “gtag_id”: “<GA_MEASUREMENT_ID>”,
    “config” : {
    “<GA_MEASUREMENT_ID>”: { “groups”: “default” }
    }
    }
    }

    I initially was using the second code and I thought that my AMP pages weren’t being tracked. Google analytics was not showing any /amp pages. However, when I changed the code to the first code, /amp pages started showing up in analytics. However, my traffic shown is now much lower.

    Is it possible that the second code (which I was initially using) was counting AMP pages, but that they were showing as their canonical versions rather than the /AMP versions?

    I am sorry if this is the wrong place to ask. However, I am very confused!

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

Viewing 1 replies (of 1 total)
  • When you add the Analytics code to your site any visits to your site served via AMP cache are counted in your Analytics tracking. If you look at the user identification section on this page it explains how it works. There is also a section on this help center article that describes how to setup a dedicated report for traffic between AMP and non AMP if you want more in dept tracking.

    In relation to your second question the first example defines your Google Analytics account ID, while the second uses a tag manager ID method. The triggers are optioning additional tracking metrics. Both of the implementations work.

    You could also implement analytics via Site Kit, which inserts the tracking code to your site for both AMP and non AMP.

Viewing 1 replies (of 1 total)

The topic ‘Analytics with AMP Cache’ is closed to new replies.