The Business 💰 Value of Speed 🏎 - A How-To Guide - Part 2: Metrics and mapping of Business Values
Tags: webperf, webdev
Published: 2020-07-22 16:19:50

Last week I wrote the [first post](https://marcradziwill.com/blog/business-value-of-speed-part-one-critical-rendering-path) of this series. In this part, I want to show you a simple method to measure essential performance metrics and map them to standard business metrics.

The [first post](https://marcradziwill.com/blog/business-value-of-speed-part-one-critical-rendering-path) covers the details of the Critical Rendering Path and therefore explains the sequence of steps to the first pixel. If you haven't read the first part, I recommend you to do so.

I publish one post of the series a week, so [stay tuned](https://marcradziwill.com/newsletter/) for the next three weeks.

- Week 1: [Critical Rendering Path](/business-value-of-speed-part-one-critical-rendering-path)
- Week 2: [Measure Key Metrics and map them to Business Metrics](/business-value-of-speed-part-two-metrics-and-mapping-of-business-values)
- Week 3: [Optimizing for your Business value](https://marcradziwill.com/blog/business-value-of-speed-part-three-optimizations/)
---

If you like this article, smile for a moment, please share it, follow me and [subscribe to my newsletter](https://marcradziwill.com/newsletter/).

---

## Tldr;

This post is the second of the series about how to get the business value of site speed. In this part, we dive into standard and custom metrics and map them to common business metrics like conversion or bounce rate.

## Table of Contents

1. [Introduction](#into)
2. [Collect the nessessary data](#data)
   - [Metrics](#metrics)
     - [Navigation Timing API](#ntapi)
     - [The Web Vitals and custom metrics.](#vitals)
3. [Mapping Business Values to Performance metrics](#mapping)
   - [Calculate the revenue](#revenue)
4. [What about causality?](#causality)
5. [Conclution](#conclution)
6. [Next steps](#next)

## 1. Introduction <div id="into"></div>

If you ever had a sales or marketing role in your career, you might know the two sweet words: closed-won. Closed-won means that the purchase has been made. We all aim for more closed-won. Probably we have different names for it, but the core stays the same.

We also know that `faster === better`. That's simple. Faster sites have better results. But this is useless to us if we do not have any useful mapping. Therefore we want to know, "**How much faster and how much better**". To archive this, we need to map our performance metrics to business metrics. Surprisingly this is much simpler as it sounds.

If you have an online shop, a blog or any other online business, you probably already measure some of these metrics: The conversion rate of your newsletter subscription or your excellent product you sell in your shop. In this post, I show you some essential metrics you should measure and how you can map them to your business metrics.

**With these reports, you can talk about performance on the manager level**. Your stakeholder probably isn't interested in the number of third party request, the total blocking time of the main thread or number of unused CSS selectors.

But **stakeholders are interested in the possibility of an increased conversion rate**, and they are interested in higher revenue. No matter what it is, that makes you read this article, if you have your own online business or if you want to convince your boss, the following steps can help you to establish a performance culture and make your business better.

## Collect the nessessary data <div id="data"></div>

When you run Google Lighthouse in your browser, you get a good overview of how your site performs in a particular environment. Like in a lab. The data you get is excellent to make improvements on your site when you already know where you want to optimize your website.

But for the Business Value of Speed, we need **data from the field**. This method of collecting data is called Real User Monitoring or pure RUM. Whereas Lighthouse measures the data on your computer, with your network connection RUM collects the data from real users.

There are plenty of great **tools** you can use, but most of them are quite expensive to set up. Fortunately, there are some alternatives that you can use for free or with a minimum of costs. In this article, I use Google Analytics and some client-side scripts to show you a free method to collect field data.

Before we dive into the measurement, let's take a look onto the metrics.

### Metrics <div id="metrics"></div>

In the first part, I wrote much about the Critical Rendering Path, and it's a sequence of steps until to user sees something or can interact with the page. Modern browsers give us the possibility to make the timings visible with the [Navigation Timing API](https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API). Check out [all supported browsers](https://caniuse.com/#feat=mdn-api_performancenavigationtiming).

#### Navigation Timing API <div id="ntapi"></div>

If your browser supports the Navigation Timing API, you can view the results in the console tab of the Chrome Dev Tools. Copy and paste the following snippet `window.performance.timing` to your console and hit enter. You get the PerformanceTiming Object like the one below. It has multiple entries with a Unix timestamp.

```js
PerformanceTiming {
navigationStart: 1595247273900,
unloadEventStart: 0,
unloadEventEnd: 0,
redirectStart: 0,
redirectEnd: 0,
connectEnd: 1595247273906
connectStart: 1595247273906
domComplete: 1595247274786
domContentLoadedEventEnd: 1595247274333
domContentLoadedEventStart: 1595247274317
domInteractive: 1595247274203
domLoading: 1595247273922
domainLookupEnd: 1595247273906
domainLookupStart: 1595247273906
fetchStart: 1595247273906
loadEventEnd: 1595247274789
loadEventStart: 1595247274786
navigationStart: 1595247273900
redirectEnd: 0
redirectStart: 0
requestStart: 1595247273910
responseEnd: 1595247273911
responseStart: 1595247273911
secureConnectionStart: 0
unloadEventEnd: 0
unloadEventStart: 0
...
```

With this PerformanceTiming object, you can measure most of your technical performance metrics. Assuming that we are using Google Analytics, it is even more straightforward. Google already measures some parameters for us. You can view them in 'Behavior -> Site Speed'. In most cases, these metrics fit all your needs. The following overview shows you the metrics in Google Analytics that you already measure if you insert the analytics script.

- Domain look up time = domainLookupEnd — domainLookupStart;
- server connection time = connectEnd — connectStart;
- server response time = responseStart — requestStart;
- page download time = responseEnd — responseStart;
- dom interactive time = domInteractive — navStart;
- dom contentLoaded time = domContentLoadedEventStart — navStart;
- page load time = domComplete — navStart;

Keep in mind that Google Analytics only measures 1% of your sessions speed data. But you can increase the Site Speed Sampling Rate quickly.

#### The Web Vitals and custom metrics <div id="vitals"></div>

What if you don't use Google Analytics or if you have custom timings? Not all businesses are equal. If you have a session time of more than [40 minutes](https://simplified.dev/performance/impact-of-web-performance), you probably need custom metrics. Additionally, some of the parameters you can collect are more important than others. Google introduced Web Vitals. I wrote a [blog post](https://marcradziwill.com/blog/introducing-the-core-web-vitals-for-a-healthy-website) about them and why you should measure them. The Core Web Vitals subset cover three fields of web performance shown in three metrics and their thresholds.

- Largest Contentful Paint (LCP) <div id="lcp"></div>
  The LCP measures loading performance. Your LCP should occur within 2.5 seconds of when the page first starts loading.

- First Input Delay (FID) <div id="fid"></div>
  FID measures interactivity. Pages should have an FID of less than 100 milliseconds.

- Cumulative Layout Shift (CLS) <div id="cls"></div>
  CLS measures visual stability. Pages should maintain a CLS of less than 0.1.

The following code examples show how to send your metrics to Google Analytics.

```js
import { getCLS, getFID, getLCP } from 'web-vitals';

function sendToGoogleAnalytics({ name, delta, id }) {
  ga('send', 'event', {
    eventCategory: 'Web Vitals',
    eventAction: name,
    eventValue: Math.round(name === 'CLS' ? delta * 1000 : delta),
    eventLabel: id,
    nonInteraction: true,
  });
}

getCLS(sendToGoogleAnalytics);
getFID(sendToGoogleAnalytics);
getLCP(sendToGoogleAnalytics);
```

What if you need a custom metric? This could be "Time to first click", "[Frames per second after click](https://simplified.dev/performance/impact-of-web-performance)" and other timing metrics that describe your users experience the best. While we are working with Google Analytics, you can send an event like the Web Vitals event above to measure the timings. In my case, I measure the following metrics among some others.

```js
dns: timing.domainLookupEnd - timing.domainLookupStart;
connect: timing.connectEnd - timing.connectStart;
basePage: timing.responseEnd - timing.responseStart;
frontEnd: timing.loadEventStart - timing.responseEnd;
```

As you see, measuring field data isn't very hard to do and probably you already doing it with you Google Analytics script. If you want to dive a bit deeper into the field data and use a more sophisticated tool, I recommend you to take a look at the [open source tool boomerang](https://github.com/akamai/boomerang). Furthermore, you find a [detailed installation guide](https://www.tollmanz.com/rum-monitoring-boomerang-boomcatch-datadog/) how to implement boomerang with boomcatch and some data visualisation tool.

## 3. Mapping Business Values to Performance metrics <div id="mapping"></div>

Now let's get it started! Mapping business values to performance metrics. In this case, I use Google Analytics to show you the correlation between the Page Load and the Conversion Rate. We do this by setting up a custom report in analytics.

1. Create a Custom Report

First, we create a custom report like in the image below.

![Creating new Google Analytics Report](https://marcradziwill.com/static/6f7fe50f7d70f696b83cdb8edce5638c/dd104/reportnew.png 'Creating new Google Analytics Report')

2. Add a Metric Group and Dimensions

Then you need to add metrics to a metrics group and add a dimension. I chose `Bounce Rate`, `Ecommerce Conversion Rate` and `Sessions` and as Dimension `Landing Page`.

![Google Analytics Report Details](https://marcradziwill.com/static/c724f985d5ca9628f00e89b5088cb624/49853/reportdetails.png 'Google Analytics Report Details')

Now you should see the average page time load correlating with the e-commerce conversion rate. You can set these correlations between the timing metrics Google Analytics already provides for you, or you can use your custom events.

### Calculate the revenue <div id="revenue"></div>

If you want more and if you have access to all of your data, you could even make a proof of concept and calculate the revenue you had due to performance optimizations or make some assumptions for future performance improvements. How can you do this? web.dev provides a [step by step guide](https://web.dev/value-of-speed/) how to calculate your revenue.

## 4. What about causality? <div id="causality"></div>

You always have to keep in mind that "Correlation does not imply causation!". There are still other effects that can mess up your data. If you want to have a clean set of data, you need to set up some tests. And of course, If you want to know more about that [reach out to me](https://marcradziwill.com/contact/).

## 5. Conclution <div id="conclution"></div>

Where are we now? In the last part of my series, you read much about the Critical Rendering Path and what the browser needs to do before it can display your site. In this part, we talked about the relevant metrics and how you can map them to business values in Google Analytics. You probably can do this as well with other analytics tools. All you need to do is to measure the timings and the business metrics per session.

In part three, I write about simple and complex optimizations for the Critical Rendering Path and your key metrics. I publish part three next week, so [stay tuned](https://marcradziwill.com/newsletter/).

## 6. Next steps <div id="next"></div>

You find all the resources for this article on [GitHub](https://github.com/marcradziwill/critical-rendering-path-tutorial). Feel free to check it out, try some stuff or fork it.

Now you have an understanding of how you Business values can map to performance metrics.

If you like this article, smile for a moment, share it, follow me, [check out my RSS feed](https://marcradziwill.com/blog/rss.xml) and [subscribe to my newsletter](https://marcradziwill.com/newsletter/).

Cheers Marc

- [Value of Speed](https://web.dev/value-of-speed/)
- [Buddy Brewer :: Taking the Guesswork out of Performance Budgets :: #PerfMatters Conference 2019](https://www.youtube.com/watch?v=rdvdPjIe27U&list=PLSmH2HL6l9pw47J-xWZSIH7HpEgqlGiXD&index=21&t=0s)
- [The Impact of Web Performance](https://simplified.dev/performance/impact-of-web-performance)
- [The Business Value of Site Speed — And How to Analyze it Step by Step](https://insights.project-a.com/the-business-value-of-site-speed-and-how-to-analyze-it-step-by-step-b01658e126cb)
- [GitHub boomerang](https://github.com/akamai/boomerang)
- [A Low Cost Performance Monitoring Setup with Boomerang, Boomcatch, and Datadog](https://www.tollmanz.com/rum-monitoring-boomerang-boomcatch-datadog/)