question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide examples to collect Web Vitals from AMP enabled Websites using GA and GTM

See original GitHub issue

I use Google Tag Manager for AMP enabled wordpress site. And it currently has a generic page view tracking thanks to Google Site Kit Plugin.

I can’t place web-vitals script from GTM anymore as it is not supported in AMP container. But I recently found out that you can use amp-analytics with built in variables like this.

<amp-analytics type="googleanalytics">
	<script type="application/json">
        {
          "vars": {
            "gtag_id": "UA-XXXXXXXXX-X",
            "config": {
              "UA-XXXXXXXXX-X": {
                "groups": "default"
              }
            }
          },
          "triggers": {
            "default pageview": {
              "on": "visible",
              "request": "pageview",
              "vars": {
                "title": "{{title}}"
              },
              "extraUrlParams": {
                "lcp": "${largestContentfulPaint}",
                "cls": "${cumulativeLayoutShift}",
                "fid": "${firstInputDelay}"
              }
            }
          }
        }	
	</script>
</amp-analytics>

But honestly, I have no idea how this value gets mapped on the google analytics. Also, I don’t have enough knowledge to fit the same setting in Google Tag manager.

So If you could add instructions for AMP enabled websites as well it would be a great addition to the documentation.

The AMP enabled websites are only 0.1% of total websites in the web. But people like me switched to AMP mainly for Core-Web-Vitals benefit. So If you could provide a consistent way to test the results, It would be helpful.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
raja-anbazhagancommented, May 6, 2021

And for Google Tag Manager for AMP, the AMP Variables setup in GTM escapes the $ signs by default.

image

Guess we can ignore GTM for now.

1reaction
philipwaltoncommented, May 6, 2021

Sorry for the slow response. I’m actually not familiar with how AMP reports this data through GTM either. @kristoferbaxter any idea who we can route this to?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to send Web Vitals event to Google Analytics from AMP ...
Before enabling AMP, I used to track web-vitals via https://web-vitals-report.web.app/ and I send events through web-vital script from ...
Read more >
Track Core Web Vitals In GA4 With Google Tag Manager
A guide for measuring Core Web Vitals (LCP, FID, and CLS) in Google Analytics 4 using Google Tag Manager and a custom template...
Read more >
How to track AMP Pages with Google Analytics 4 - David Vallejo
There is some data provided by AMP that is available and that can provide some cool events, in this first release I've added...
Read more >
Implementing Google Analytics in AMP Websites Using ...
Google Tag Manager for websites gives us triggers that can track page views, clicks on a certain element, sending a form and custom...
Read more >
Google Tag Manager Use Cases - 99 Ideas - Analytics Mania
#2. Track page views of a single-page website or web application. #3. Track Accelerated Mobile Pages (AMP). Keep in mind that AMPs ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found