Google Analytics 4 Calculated Metrics with Examples

Last Updated: October 18, 2023

What is a Calculated Metric in GA4?

‘Calculated metric’ is a type of user-defined metric. Another type of user-defined metric in GA4 is the ‘custom metric’. 

Calculated metrics are used to perform calculations on existing metrics. 

For example, 

  • The addition of two or more metrics.
  • Multiplicating two or more metrics.
  • Dividing a metric by a constant, etc. 

A calculated metric is useful when understanding ratios, percentages, or other derived values from existing metrics. 

For example, if you wanted a metric for “% of new users,” you could create a calculated metric dividing “New users” by “Total users.”

create a calculated metric
calculated metric ga4

Calculated metrics are ideal whenever you want to report on a compound metric in GA4.

You can access calculated metrics in reports, explorations, and GA data API.

You can create up to 5 calculated metrics per standard GA4 property and 50 calculated metrics per GA4 360 property.

A Calculated metric differs from a ‘custom metric’ in how it is configured, collected and processed in Google Analytics 4.

Key differences between custom metrics and calculated metrics.

In GA4, both custom metrics and calculated metrics allow users to tailor the platform to specific tracking needs.

However, they serve different purposes and have distinct characteristics. 

Following are the key differences between custom metrics and calculated metrics in GA4

#1 ‘Custom metric’ is used to collect the data which GA4 does not automatically collect (like phone call data, CRM data, etc). Whereas a ‘‘Calculated metric’ is used to collect/compute new data from the already available data in GA4. 

#2 Unlike ‘custom metrics’, the ‘calculated metrics’ are derived from existing metrics and are defined using a mathematical formula. You combine or manipulate existing metrics to generate a new metric value.

#3 The values of a custom metric are processed and reported in GA4 only when the new data is available in GA4. 

Whereas the values of the calculated metric are processed and reported as soon as the calculated metric is configured. Because of this reason, you can see data for your calculated metrics as soon as you set them up.

#4 Custom metrics do not work retroactively, i.e. they do not collect and report on historical data. Whereas calculated metrics can work retroactively, i.e. they can collect and report on historical data.

#5 Custom metrics are not compound metrics, i.e. their value does not depend upon the value of other metrics. 

Whereas calculated metrics are compound metrics. The advent of calculated metrics allows the creation of compound metrics in GA4.

#6 Custom metrics depend on the current tracking setup. The custom metric won’t collect data if the tracking doesn’t fire or is broken.

Calculated Metrics depend on the existing metrics. If the underlying metrics have issues or discrepancies, the calculated metric might also be inaccurate.

Attributes of a calculated metric.

A calculated metric has the following five attributes:

  1. Name
  2. API Name
  3. Description
  4. Formula
  5. Unit of measurement
Attributes of a calculated metric

#1 Name

This is a web view name (or User interface name) of a calculated metric.

We identify a metric in a GA4 report through its web view name.

web view name or User interface name of a calculated metric
web view name of a calculated metric

Using descriptive names for your calculated metrics is a good practice so that a report recipient can easily understand what the metric is all about and/or what data it should report upon.

For example, ‘CalcMetric1’ is a bad name for a calculated metric.

‘% of New Users’ is a good name for a calculated metric, as it clearly defines what the metric is all about.

Note(1): The web view name must be unique across all calculated and custom metrics. 

Note(2): You can change the web view name of a calculated metric any time you like, and it will work retroactively.

#2 API Name

This is the ‘API name’ of the calculated metric.

When we access Google Analytics directly via API, we use the API name of a metric/dimension, instead of the web view name. 

For example, the API name for the calculated metric we created earlier is: ‘calcMetric:_of_new_users’:

the ‘API name of the calculated metric

Google automatically creates the API name for your calculated metric based on the value in the ‘Name’ field.

But you can change it to something else if you like.

However, once the calculated metric is set up, you can’t change its API name again.

Note(1): The API name must be unique across all calculated and custom metrics. However, if you archive the calculated metric, you can use the API name for a different calculated metric.

Note(2): The API name can only contain alphanumeric characters and underscore. Special characters, symbols, and spaces are not allowed.

#3 Description

Description of calculated metric in ga4

Whatever text you enter in the ‘Description’ field appears as a help tip when a user hovers his mouse over the calculated metric in a GA4 report:

the ‘Description field appears as a help tip

#4 Formula

The formula is an arithmetic expression that must return a numeric value.

An arithmetic expression is made up of numbers, arithmetic operators (+, -, *, / ) and sometimes parenthesis.

Following are examples of arithmetic expressions:

1+3

1-3

1*3+4.21 /100

100 + (1 +(250 / 108)) * 3.561

However, unlike regular arithmetic expressions, the expression used to compute calculated metrics should not be made up of just constants.

It must include at least one metric.

For example, you won’t be able to use the following custom metric in your report even though it is made up of a valid formula:

formula calculated metric
this calculated metric is not available

Your calculated metric should include at least one metric. 

You can use the following arithmetic operators in your formula:

– (minus or negative)

+ (addition)

* (multiplication)

/ (division)

() (parenthesis)

Metric names must be surrounded by single curly brackets {}

For example:

{New users}

{Total users}

Metric names must be surrounded by single curly brackets

Use parenthesis to override operator precedence.

Parenthesis are allowed in a formula. 

Just like regular arithmetic expressions, the expression used to compute calculated metrics can include parenthesis.

For example, the following formula is valid:

({New users} /{Total users}) * 100

Operator precedence can be overridden by using parenthesis. 

The order of operations (or operator precedence) is a set of rules defining which operation to perform first to evaluate a given expression.

For example, multiplication precedes addition.

All the usual operator precedence rules are applicable for the expressions which are used as formulas for calculated metrics.

Square brackets are not allowed in a formula.

For example, the following formula is invalid:

[{New users} /{Total users}] * 100

Square brackets are not allowed in a formula

GA4 automatically surrounds all metrics with single curly braces.

So, for example, if you select ‘New users’ from the drop-down menu, GA4 will automatically surround the ‘New users’ metric with single curly braces {New users} :

GA4 automatically surrounds all metrics with single curly braces

However, if you accidentally added one extra curly brace, your expression will become invalid:

you accidentally added one extra curly brace

You can also use an expression as a formula which does not include any arithmetic operator.

For example, the following formula is perfectly valid:

use an expression as a formula which does not include any arithmetic operator

You basically renamed the ‘New users’ metric as the ‘New Visitors’ metric.

Note: The expression which returns a string or the expression which returns a Boolean value (true or false) can not be used as a formula for computing calculated metrics.

You can create a calculated metric which is based on the value of a custom metric.

create a calculated metric which is based on the value of a custom metric

Note(1): You cannot create a calculated metric that is based on another calculated metric(s).

Note(2): You can change the formula used for a calculated metric any time you like, and it will work retroactively.

Note(3): Formulas are limited to 1024 characters.

Not all metrics can be used together in a formula.

One of the biggest downsides of calculated metrics in GA4 is that not all the metrics can be used together.

For example, ‘Revenue per user’ is such a basic metric to compute. But when you try to use it as a calculated metric, you get the following error message:

One or more metrics referenced in formula contains data restrictions. These restrictions will also apply to this calculated metric.

Not all metrics can be used together in a formula

#5 Unit of measurement

This configuration setting of the calculated metric is used to set the format in which GA4 should report on the values of the calculated metrics. 

There are four formatting types available in GA4 for calculated metrics:

  1. Standard.
  2. Currency.
  3. Distance (measured in feet, miles, meters, kilometres).
  4. Time (measured in milliseconds, seconds, minutes, hours).

You can select these formatting types from the ‘Unit of measurment’ drop-down menu:

the ‘Unit of measurment drop down menu
the ‘Unit of measurment drop down menu 2

#1 Standard

the ‘Standard unit of measuremen

Use the ‘Standard’ unit of measurement if the value of your calculated metric is an integer or floating point number.

An integer is a whole number. It is a number without a decimal point, and it can be positive (like 12), negative (like -12) or Zero (0).

However, Google Analytics supports only positive integers and zero for the computation of calculated metrics.

Negative integers are not supported.

A floating point number is a number that has digits after the decimal point.

A floating point number can be a positive or negative number, but in the case of GA, it needs to be a positive number.

GA does not support negative floating point numbers for computing calculated metrics.

The following examples of floating point numbers are valid for creating a calculated metric:

2.34, 1.98, 3.00, .45, 9.0, etc.

Following is an example of a floating point number that is invalid for creating a calculated metric: ‘-2.34’. 

Also worth noting is that Google Analytics can consider any number of digits after the decimal point in its computation of calculated metrics but always report floating point numbers with only two digits after the decimal point.

For example, the following formula:

{Total Revenue} * .01

can produce different output than the formula one below:

{Total Revenue} * .006

or the formula one below:

{Total Revenue} * .006009

Here, GA4 will not round off the number .006 or .006009 to .01 but instead, use the number .006 or .006009 to compute the calculated metrics’ value.

However, GA4 will always report a floating point number with only two digits after the decimal point and, in case of reporting, may round off a number to the two decimal digits.

So if the Total revenue is say $50,000 then the computed value for the calculated metrics could be:

$50000 * .01 = $500.00  (according to the formula: {Total Revenue} * .01)

Or

$50000 * .006 = $300.00 (according to the formula: {Total Revenue} * .006 )

Or

$50000 * .006009 = $300.45 (according to the formula: {Total Revenue} * .006009)

#2 Currency

the ‘Currency unit of measurement

Use the ‘Currency’ unit of measurement if the value of your calculated metric is a currency.

In the context of GA4, currency combines a currency symbol and a floating point number. 

The currency symbol that is used is the one that is set up under your property settings:

5QqsIs4UnXaNkKYhMO7oFxoKQfTKeNh77rN7WugxKjSDADZezrywMah202aTxrrRi

So, for example, if US Dollar is set up under ‘currency displayed as’ setting then the values of your calculated metric will be displayed in USD.

#3 Distance

GA4 measures distance in feet miles meters or kilometres

GA4 measures distance in feet, miles, meters or kilometres.

Use one of the ‘Distance’ units of measurement if the value of your calculated metric represents distance. 

#4 Time

GA4 measures time in milliseconds seconds minutes or hours

GA4 measures time in milliseconds, seconds, minutes or hours.

Use one of the ‘Time’ units of measurement if the value of your calculated metric represents time. 

How to create a calculated metric in GA4?

Follow the steps below:

#1 Navigate to the admin area of your GA4 property:

admin area of your GA4 property

#2 Click on the link ‘Custom definitions’ under the ‘Property’ column:

Custom definitions ga4

#3 Click on the ‘Calculated Metrics’ tab:

Calculated Metrics ga4

#4 Click on the ‘Create calculated metric’ button:

Create calculated metric

#5 Enter the name, API name (if required), description, formula and unit of measurement and then click on the ‘Save’ button:

save calculated metric

You should now see the new calculated metric listed in the data table:

see the new calculated metric listed in the data table

How to use a calculated metric in GA4

Follow the steps below:

#1 Click on ‘Explore’:

explore ga4

#2 Click on ‘Blank’ to create a new exploration report:

create a new exploration report

#3 Name your report ‘Calculated metrics’ and then add the following dimension and metrics to it:

Name your report ‘Calculated metrics

You should now be able to see the values of your new calculated metric on the canvas on the right:

see the values of your new calculated metric on the canvas

My best selling books on Digital Analytics and Conversion Optimization

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution Modelling in Google Analytics and BeyondSECOND EDITION OUT NOW!
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.

Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.

About the Author

Himanshu Sharma

  • Founder, OptimizeSmart.com
  • Over 15 years of experience in digital analytics and marketing
  • Author of four best-selling books on digital analytics and conversion optimization
  • Nominated for Digital Analytics Association Awards for Excellence
  • Runs one of the most popular blogs in the world on digital analytics
  • Consultant to countless small and big businesses over the decade