Sub topic 11
Custom dimensions and metrics: making parameters reportable
This chapter assumes you know that GA4 records every interaction as an event, and that an event can carry parameters. You should be able to read basic gtag JavaScript. The BigQuery section assumes basic SQL.
The problem: collected is not the same as reportable
When you send an event, GA4 stores every parameter you attach. Most of those parameters are not visible in the standard reports or in Explorations until you register them.
Registering a parameter creates a custom definition. A custom definition is a rule that tells GA4 to take one event parameter or user property and expose it as a field in reporting. A custom definition comes in two kinds:
- A custom dimension is a text-like attribute you group or filter by, such as
tutorial_name. - A custom metric is a number you sum or average, such as
step_numberorshipping_cost.
Consider this event.
// Send a custom event with a custom parameter
gtag('event', 'tutorial_step_completed', {
step_number: 3,
tutorial_name: 'ga4_data_model'
});GA4 collects this event immediately. You can see the event name in the event reports. You cannot break down a report by tutorial_name until you register it as a custom dimension.
Scopes: what the definition describes
Each custom dimension has a scope. The scope says which level of the data the value belongs to.
| Scope | Source | Meaning | Example |
|---|---|---|---|
| Event | Event parameter | The value describes one event | `tutorial_name` |
| User | User property | The value describes the person across events | `plan_type` |
| Item | Item parameter | The value describes a product in the `items` array | `item_color` |
Custom metrics are available at event scope. They take a numeric event parameter.
The scope decides how the value behaves in a report. An event-scoped dimension can change from one event to the next. A user-scoped dimension holds the most recent value GA4 has seen for that user, and it applies to the user's events. Pick the scope that matches what you are describing. A plan type belongs to the user. A button label belongs to the event.
Registering a custom dimension
You register definitions in the Admin area of the property. You need the Editor role or higher on the property to do this.
- Open Admin, then Data display, then Custom definitions.
- Choose Create custom dimension.
- Enter a Dimension name. This is the label people see in reports, for example "Tutorial name".
- Choose the Scope: Event, User, or Item.
- Choose the Event parameter (or User property) from the list. If your parameter has already been collected, it appears in the dropdown. You can also type the exact name.
- Optionally add a description, then save.
The parameter name must match exactly. GA4 names are case sensitive, so Tutorial_Name and tutorial_name are two different parameters. A definition for one will not capture the other.
Registering a custom metric
A custom metric needs the same steps, plus a unit of measurement. Choose Standard, Currency, Feet, Meters, Kilometers, Miles, Milliseconds, Seconds, Minutes, or Hours. The unit controls how the number is formatted. For the step_number parameter above, Standard is the right choice.
Be careful here. A sum of step_number across events is rarely useful, because step numbers are labels more than quantities. If you only want to group by step, make step_number a custom dimension instead. Use a custom metric when adding or averaging the value makes sense, such as a delivery fee, a quiz score, or a video length.
What happens after you register
Three behaviors surprise people.
- No backfill. A definition applies from the moment you save it. Data collected earlier is not reprocessed, so historical reports stay empty for that field. Register definitions before launching the tracking, or as soon as you decide you need them.
- Processing delay. A new dimension can take up to 24 hours to populate in standard reports. DebugView and the Realtime report may show parameters sooner, but standard reports lag.
- Registration is not retroactive in the other direction. Deleting or archiving a definition frees its slot, but the raw parameter is still in the event data and still in BigQuery.
Because of the no-backfill rule, the BigQuery export is your safety net. The raw event_params are exported whether or not you registered them, so you can still analyze history that GA4 reports cannot show.
Limits
Each property has a fixed quota of custom definitions. The standard (free) property limits at the time of writing are:
| Definition type | Standard property limit |
|---|---|
| Event-scoped custom dimensions | 50 |
| User-scoped custom dimensions | 25 |
| Item-scoped custom dimensions | 10 |
| Custom metrics | 50 |
GA4 360 properties have higher limits. Check the current Analytics Help page before you plan a large schema, because Google changes quotas.
Other limits affect what you send:
- Event names can be up to 40 characters, and parameter names up to 40 characters.
- A parameter value can be up to 100 characters for standard properties.
- An event can carry up to 25 parameters.
- A property can hold up to 500 distinct event names for a web stream.
Values longer than the limit are truncated or dropped, which silently damages a report. Keep values short and consistent.
Cardinality and the "(other)" row
Cardinality is the number of distinct values a dimension has. A dimension with values like free and premium has low cardinality. A dimension holding a full URL with a session token, or a timestamp, has very high cardinality.
When a report contains too many unique values, GA4 groups the overflow into a row labeled (other). High-cardinality custom dimensions are a common cause. They also make reports hard to read. Do not register parameters such as user_id, a raw timestamp, a search string with free text, or a unique transaction token as dimensions. Use a coarser form, such as a category or a bucket (1-5 items, 6-10 items).
Personal data and what not to register
Do not send or register personally identifiable information. Email addresses, phone numbers, and full names violate Google Analytics policies. A custom dimension called "Email" does not become acceptable because it is custom. Use an internal, non-identifying ID instead, and see the earlier chapter on User-ID for how that link works.
A worked example: user and event scopes together
The next snippet sets a user property and a User-ID, and then sends an event.
// Set a user property and a User-ID for signed-in visitors
gtag('set', 'user_properties', {
plan_type: 'premium'
});
gtag('config', 'G-XXXXXXXXXX', {
user_id: 'u_12345'
});
// Send a custom event with a custom parameter
gtag('event', 'tutorial_step_completed', {
step_number: 3,
tutorial_name: 'ga4_data_model'
});To report on this data, you would register these definitions:
| Name in reports | Scope | Source name | Type |
|---|---|---|---|
| Plan type | User | `plan_type` | Dimension |
| Tutorial name | Event | `tutorial_name` | Dimension |
| Tutorial step | Event | `step_number` | Dimension |
With these in place, you can build an Exploration with "Tutorial name" as a row, "Plan type" as a column, and "Event count" as the value. That table answers whether premium users complete more tutorial steps than free users.
Using registered fields in reports
After the definition populates, the field is available in several places:
- Explorations as a dimension or metric you drag into the tab settings.
- Standard reports after you add it as a secondary dimension, or add it to a customized report in the report library.
- Audiences and segments as a condition.
- The Google Analytics Data API, using the API name. Event-scoped dimensions use
customEvent:tutorial_name, user-scoped dimensions usecustomUser:plan_type, and custom metrics usecustomEvent:plus the parameter name.
The field's API name is built from the parameter name, not from the display name you chose. If you rename the display name later, API calls continue to work.
Checking raw data in BigQuery
Registration affects reports. It does not change what is exported. In the BigQuery export, an unregistered parameter is still a row inside the event_params array. This query reads the tutorial_name parameter even if it was never registered.
-- Count tutorial steps by tutorial name from the raw export
SELECT
(SELECT ep.value.string_value
FROM UNNEST(event_params) AS ep
WHERE ep.key = 'tutorial_name') AS tutorial_name,
COUNT(*) AS steps_completed
FROM `my-project.analytics_123456789.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20240101' AND '20240131'
AND event_name = 'tutorial_step_completed'
GROUP BY tutorial_name
ORDER BY steps_completed DESC;The value field is a record with several typed members: string_value, int_value, float_value, and double_value. You must read the member that matches how the value was sent. In the first snippet, step_number: 3 was sent as a number, so it lands in int_value. Reading string_value would return NULL.
Common mistakes
- Registering after the fact and expecting history. Definitions do not backfill. Use BigQuery for earlier data.
- A name mismatch. A typo or a case difference means the dimension stays empty. Compare the name in DebugView with the name in the definition.
- Using the wrong scope. A user-level fact registered at event scope will be missing from events that did not send it.
- Registering high-cardinality values. You get
(other)rows and wasted quota. - Making a numeric label a metric. Summing step numbers or IDs gives a meaningless total.
- Changing a value's type. Sending
3on one page and"3"on another splits the data betweenint_valueandstring_valuein BigQuery, and can confuse the report. - Spending quota on parameters you never use. Plan the schema first, then register only what a report will use.
Summary
A parameter is stored when you send it, but it becomes a reportable field only after you register it as a custom dimension or metric. Choose the scope that matches what the value describes. Keep names exact, values short, and cardinality low. Remember that registration is not retroactive, and that BigQuery always holds the raw values.
Exercise
Your team has sent a video_title event parameter for three months. Today you register it as an event-scoped custom dimension. The next morning, an Exploration shows the dimension for today's events only. Why, and how can you analyze the earlier three months?
Show answer
Custom definitions apply only from the time they are saved, and GA4 does not reprocess earlier data. The earlier values are still in the raw event data, so you can query the BigQuery export, reading the video_title entry from event_params with UNNEST and ep.value.string_value, for the earlier date range.
Exercise
A developer wants to register plan_type ("free" or "premium") and delivery_fee (a dollar amount such as 4.50). Which scope should each use, and should each be a dimension or a metric?
Show answer
plan_type describes the person, so it is a user-scoped custom dimension, set as a user property. delivery_fee is a number you can sum or average, so it should be an event-scoped custom metric with the Currency unit.
Exercise
You registered a dimension called "Tutorial name" from the parameter Tutorial_Name, but your code sends tutorial_name. The report column is empty. What is wrong, and how do you fix it?
Show answer
Parameter names are case sensitive, so the definition watches a different parameter than the one being sent. Create a new definition using tutorial_name (or change the code to send Tutorial_Name). Wait for processing, since new data may take up to 24 hours to appear in standard reports.