Google Analytics Tracking Event FP_FCP

Google Analytics Guide
Post Reply
User avatar
Forum Admin
Posts: 11
Joined: 15 May 2020, 22:56
Location: Sweden

Google Analytics Tracking Event FP_FCP

Post by SEO_Forum »

With this code you can tracking FP_FCP ” first contentful paint”.

Code: Select all

  <!-- Add the async Google Analytics snippet first. -->
  <script>||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
  ga('create', 'UA-XXXXX-Y', 'auto');
  ga('send', 'pageview');
  <script async src=''></script>

  <!-- Register the PerformanceObserver to track paint timing. -->
  const observer = new PerformanceObserver((list) => {
    for (const entry of list.getEntries()) {
      // `name` will be either 'first-paint' or 'first-contentful-paint'.
      const metricName =;
      const time = Math.round(entry.startTime + entry.duration);

      ga('send', 'event', {
        eventCategory: 'Performance Metrics',
        eventAction: metricName,
        eventValue: time,
        nonInteraction: true,
  observer.observe({entryTypes: ['paint']});

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest