Sub topic 2
Event parameters: describing what happened
This chapter assumes you know what a GA4 event is, can find Admin and your data stream, and can read basic JavaScript or use Google Tag Manager (GTM). It covers event parameters: what they are, how GA4 treats them, and the mistakes that make them disappear from reports.
What an event parameter is
A GA4 event records that something happened, such as page_view, purchase or select_plan. The event name alone says little. An event parameter is a key-value pair attached to one event hit that adds detail. For select_plan, the parameters could be which plan was chosen and how it is billed.
Parameters belong to a single event occurrence. They are not remembered for later events. If you send plan_tier: 'pro' with select_plan, the next event, begin_checkout, does not carry it unless you send it again. This is the main difference from user properties, which GA4 attaches to later events from the same user (a later chapter covers them).
gtag('event', 'select_plan', {
plan_tier: 'pro',
billing_cycle: 'annual'
});This call sends one event named select_plan with two custom parameters. GA4 stores both as part of the event.
Where parameters come from
Parameters fall into three groups.
| Group | Examples | Notes |
|---|---|---|
| Automatically collected | `page_location`, `page_referrer`, `ga_session_id`, `engagement_time_msec` | Sent with most events. Some appear as built-in dimensions. |
| Recommended | `currency`, `value`, `transaction_id`, `method` | Defined by Google for specific events, such as `purchase` and `login`. |
| Custom | `plan_tier`, `billing_cycle` | Defined by you. This chapter focuses on these. |
Using a recommended parameter name where one exists is better than inventing your own. GA4's built-in reports and some features are built around those names.
Collected is not the same as reportable
GA4 stores every parameter you send in the raw event data. Most parameters do not show up in standard reports, Explorations or audiences by default. A parameter becomes a dimension or metric in those tools only after you register it as a custom definition in Admin.
- Register a text parameter, or a numeric one you want to group by, as a custom dimension.
- Register a numeric parameter you want to sum or average as a custom metric.
Until you do that, the data exists, but you can only see it in DebugView, in the BigQuery export if it is enabled, or in the raw event stream. Later chapters cover registration. For now, remember that sending a parameter and reporting on it are two separate steps.
Anatomy of a good parameter
A parameter has a name and a value. Both have rules.
Names
- Use lowercase letters, digits and underscores, and start with a letter. Snake case such as
billing_cycleis the convention. - Keep names within 40 characters. Longer names are not accepted.
- Avoid reserved prefixes:
google_,ga_andfirebase_. - Avoid names that clash with built-in parameters or reserved names. A clashing custom parameter can be ignored or can overwrite expected behavior.
- Names are case-sensitive.
Plan_Tierandplan_tierare different parameters, and registering one does not capture the other.
Values
- A value is either a string or a number. Send numbers as numbers (
184), not strings ('184'), if you plan to use them as custom metrics. - A string value for an event parameter is limited to 100 characters. Longer values are truncated.
- Keep the set of possible values small and predictable. Values such as
'pro','free'and'team'group well. Free-text input does not.
Per-event limits
A single event can carry at most 25 custom parameters in standard properties. The limit applies per event, not per property. Properties have separate limits on how many parameters you can register, which a later chapter covers.
The practical effect is that you should send only parameters you have a use for. Sending many parameters on every event wastes the per-event budget, and it makes DebugView and BigQuery data harder to read.
Event-scoped custom dimensions
When you register a parameter as a custom dimension, you choose the event scope. Event scope means the value is tied to the individual event. Reports can then break down event counts by that value.
For the select_plan example, registering plan_tier as an event-scoped dimension lets you answer: how many select_plan events happened for each plan tier? Registering billing_cycle lets you split the same events by annual and monthly.
Because the scope is the event, the values in a report reflect what was sent with each event, not what was true for the user overall. If a user picks free and later picks pro, the first event counts toward free and the second toward pro.
Sending parameters from other sources
The same parameter model applies regardless of how the event gets to GA4.
Google Tag Manager
In GTM, push an event to the data layer. A GA4 event tag can then map data layer values to event parameters.
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'video_complete',
video_length_seconds: 184
});In the GA4 event tag, add a row under Event Parameters with the name video_length_seconds and a value that reads the matching data layer variable. Creating the variable is a separate step, and a missing variable is a common reason parameters arrive empty. The number 184 here is a good candidate for a custom metric, because you would want to sum or average it.
Measurement Protocol
Servers and other systems can send events with the Measurement Protocol. Parameters go in the params object of each event.
{
"client_id": "555.1234567890",
"events": [
{
"name": "offline_sale",
"params": {
"store_region": "north",
"basket_size": 4
}
}
]
}Once registered, store_region and basket_size appear in reports in the same way as parameters collected on the web.
Common errors
Most problems with event parameters come from a short list of causes.
- The parameter is registered but shows
(not set). Not every event carries the parameter. An event-scoped dimension is(not set)for any event that did not send it. Filter to the event name that sends it. - The report is empty after registration. Data collected before registration is not backfilled into the custom dimension. Only events received after you register it populate it. Allow time for processing as well, as it can take up to a day for the dimension to appear.
- The name does not match.
planTierin your code andplan_tierin Admin are different. Check the registered name against the exact string you send, including case. - The value type is wrong. A number sent as a string cannot be summed as a metric. A string sent where a number is expected does not work as a metric.
- The parameter was overwritten by the wrong value. If the same parameter is set in a tag's configuration and in the event, the event-level value wins for that event. Check both places.
- Too many unique values. A parameter such as a timestamp or a free-text search term creates a huge number of distinct values. Reports then group the excess into an
(other)row. Choose parameters that group.
Checking before you register
Before registering anything, confirm the parameter arrives with the right name and value. DebugView, covered in a later chapter, shows each event and its parameters as they arrive from a device in debug mode. Checking first avoids registering a misspelled name, which consumes one of your limited custom definition slots.
Summary of the working model
- An event parameter describes one event occurrence and is not carried to later events.
- GA4 stores any parameter you send, up to 25 custom parameters per event.
- A parameter appears in reports only after you register it as a custom dimension (to group by) or a custom metric (to sum or average).
- Registration applies going forward and does not backfill earlier data.
- Names are case-sensitive snake_case strings of at most 40 characters. String values are limited to 100 characters.
Exercise
A site sends gtag('event', 'select_plan', { plan_tier: 'pro' }) and the team registers plan_tier as an event-scoped custom dimension. A week later, an analyst sees (not set) against plan_tier for the page_view event. Is this a bug, and what two other things would explain a fully empty dimension for the days before registration?
Show answer
It is not a bug. page_view events do not send plan_tier, so an event-scoped dimension has no value for them. An empty dimension for earlier days is expected because registration is not retroactive, and events sent before it are not populated. A name mismatch (for example planTier in code) or a short processing delay after registration would also leave the dimension empty.
Exercise
You want to report the total of video_length_seconds across all video_complete events. Which kind of custom definition do you register, and what must be true of the value you send?
Show answer
Register a custom metric, because you want to sum a number. The value must be sent as a number, such as 184, not as a string such as '184'.