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.

Tracking Core Web Vitals in AMP using Google Analytics doesn't work

See original GitHub issue

Description

I added web vitals tracking in code but since then page-views tracking stopped working. Created a test page, please let me know where the issue is.

https://m.economictimes.com/amp_test.cms (PV tracking working) https://m.economictimes.com/amp_test.cms?web_vital=1 (PV tracking not working)

The only difference in the second url is, extraUrlParams has been added to track core web vitals tracking along with page views body as suggested by amp.dev

"extraUrlParams": {
    "lcp": "${largestContentfulPaint}",
    "cls": "${cumulativeLayoutShift}",
    "fid": "${firstInputDelay}"
 }

Reproduction Steps

Please check network log of analytics for the given url. Page views are not getting logged.

Browser(s) Affected

Chrome

OS(s) Affected

Android 11

AMP Version Affected

012105150310000

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
abhiz10commented, May 31, 2021

@scaledrop Hi… When you hit this URL

https://m.economictimes.com/amp_test.cms?web_vital=1

Reproduction Steps If you go to another tab and then come back to your original tab analytics data is present in Dev Tool> Network

v=1&_v=a1&ds=AMP&aip&_s=1&dt=%7B%7Btitle%7D%7D&sr=320x568&_utmht=1622481493821&cid=amp-QHLBUAD9Q3EAOfz7PnLBYw&tid=&dl=https%3A%2F%2Fm.economictimes.com%2Famp_test.cms%3Fweb_vital%3D1&dr=&sd=24&ul=en-us&de=UTF-8&t=pageview&jid=0.0021677142480029943&_r=1&a=7210&z=0.9754394625957776&lcp=88.800048828125&cls=0&fid=4

https://amp.dev/documentation/components/amp-analytics/#vars

Variables are resolved asynchronously and can delay the request until they are fulfilled. For example, some metrics such as Cumulative Layout Shift and Largest Contentful Paint are calculated after the page is hidden. For First Input Delay, it is resolved after the user interacts with the page. For this reason these metrics might not be suitable for use with all triggers (for example, on timer or visible).

0reactions
scaledropcommented, Nov 23, 2022

Thank you @micajuine-ho @abhiz10 for your inputs. Closing this thread since we got a another reference of similar open issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Core Web Vitals report - Search Console Help - Google Support
The Core Web Vitals report shows URL performance grouped by status (Poor, Need improvement, Good), metric type (CLS, FID, LCP), and URL group...
Read more >
Adding support for Google Analytics's Core Web Vitals amp ...
Google added Core Web Vitals support to Analytics, it'd require... ... You can use amp-analytics to track the 3 Core Web Vital metrics...
Read more >
Example: Tracking Core Web Vitals - amp.dev
AMP developers can measure Core Web Vitals metrics through the amp-analytics component. ... Tracking Core Web Vitals in AMP using Google Analytics.
Read more >
Google Analytics & AdSense Don't Get a Core Web Vitals Pass
Loren Baker, founder of Search Engine Journal noted that Google Analytics, Google Ads, Google Tags can negatively affect core web vitals scores.
Read more >
Core-Web-Vitals Analytics for AMP site - WordPress.org
Ensure you insert googleanalytics as the type, as there are numerous Analytics vendors that support AMP. After you've inserted your Analytics snippet manually, ......
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