Sub topic 4
Event parameters: describing what happened
This chapter assumes you know that GA4 records every interaction as an event, and that you can read basic JavaScript (gtag) and SQL. It covers what event parameters are, how they are named and typed, which limits apply, and why a parameter you send may not appear in a report.
What a parameter is
An event name says what kind of thing happened, such as add_to_cart or file_download. An event parameter is a name and value pair attached to that single event that adds detail. Parameters answer questions like which file, how much, on which page, or which step.
Two events with the same name can carry different parameter values. That is the point. You do not need a separate event name for every file, button, or product. You send one file_download event and let a file_name parameter vary.
// Send a custom event with a custom parameter
gtag('event', 'tutorial_step_completed', {
step_number: 3,
tutorial_name: 'ga4_data_model'
});Here tutorial_step_completed is the event. step_number and tutorial_name are parameters. GA4 stores them with this one event and with nothing else.
Where parameters come from
Every event can carry parameters from three sources.
| Source | Example | Who sets it |
|---|---|---|
| Automatically collected | `page_location`, `page_title`, `page_referrer`, `ga_session_id`, `engagement_time_msec` | GA4 tag, without your code |
| Recommended | `currency`, `value`, `items`, `transaction_id`, `search_term` | You, following Google's documented names |
| Custom | `step_number`, `tutorial_name` | You, with names you choose |
Prefer a recommended parameter name when one exists for your event. Reports, built-in dimensions, and the BigQuery export treat those names consistently. For example, value and currency together let GA4 compute revenue for events that use them.
Automatically collected parameters matter more than they look. The ga_session_id parameter is how GA4 ties an event to a session, and engagement_time_msec is what feeds engagement metrics. You usually do not set these yourself. If you remove or overwrite them, session and engagement numbers break.
How a parameter travels
The branch at the end causes most beginner confusion. Collection and reporting are separate steps. A parameter can be fully collected and still be invisible in the report interface. The chapter on custom dimensions and metrics covers registration in full. This chapter only explains why it is needed.
Scope: a parameter belongs to one event
An event parameter describes one event. It does not follow the user to later events, and it does not describe the session. If you send step_number: 3 on one event, the next event has no step_number unless you send it again.
You can make a value repeat on every later event with gtag('set', ...). This is useful for values such as a page-level category.
// Applies to all events sent after this call, until overwritten
gtag('set', { content_group: 'tutorials' });
gtag('event', 'tutorial_step_completed', {
step_number: 4,
tutorial_name: 'ga4_data_model'
});Be careful with this. A value set this way stays in effect for the page's lifetime in a single-page application, even after the user moves to a different view. Stale values are a common source of wrong data. If a value should describe the person across events, use a user property instead. If it should describe a single action, pass it in that event's parameter object.
Value types and formatting
A parameter value is either text or a number. GA4 decides which from what you send.
step_number: 3is stored as a number.step_number: '3'is stored as text.
The two are not the same field in the data. In BigQuery they land in different columns, as shown later. If one code path sends 3 and another sends '3' for the same parameter name, you get split or missing values. Pick one type per parameter and keep it.
Name rules to follow:
- Names are case-sensitive.
Step_Numberandstep_numberare two different parameters. - Use letters, digits, and underscores, and start with a letter. Snake case is the convention in Google's recommended events.
- Do not start a name with
google_,ga_, orfirebase_. Those prefixes are reserved. - Do not reuse a reserved name for another meaning, such as using
currencyfor something that is not a currency code.
Limits that affect design
Standard GA4 properties enforce limits on events and parameters. The numbers below are the documented values at the time of writing, so check Google's current limits page before relying on them.
| Item | Typical limit |
|---|---|
| Event name length | 40 characters |
| Parameters per event | 25 |
| Parameter name length | 40 characters |
| Parameter value length | 100 characters (some automatic ones allow more, such as `page_location`) |
| Event-scoped custom dimensions per property | 50 |
| Event-scoped custom metrics per property | 50 |
What happens when you exceed a limit depends on the item. Extra parameters beyond the cap may be dropped. A long value is truncated. Neither case raises a visible error in your page, so test with real payloads and check DebugView.
Do not send personally identifiable information in parameters. Email addresses, full names, and phone numbers violate Google's policy and can lead to deleted data.
Parameters, items, and ecommerce
Ecommerce events carry the usual scalar parameters, such as currency and value. They also carry an items array, where each element describes a product with its own fields. The next chapter covers it, so here you only need to see where it sits.
// Send a recommended ecommerce event with parameters and an items array
gtag('event', 'add_to_cart', {
currency: 'USD',
value: 29.99,
items: [
{
item_id: 'SKU_123',
item_name: 'Trail Shoe',
price: 29.99,
quantity: 1
}
]
});currency and value describe the whole event. The product details live inside items. Keep that split in mind when you choose names. Product facts belong in items, and facts about the action belong at the top level.
Reading parameters in the BigQuery export
The BigQuery export shows the storage model directly. Each row is one event. The parameters sit in a repeated record called event_params, where each element has a key and a value struct. The struct has separate fields by type: string_value, int_value, float_value, and double_value. Only one is filled for a given parameter.
-- Read one custom parameter from each tutorial_step_completed event
SELECT
event_date,
user_pseudo_id,
(SELECT ep.value.string_value
FROM UNNEST(event_params) AS ep
WHERE ep.key = 'tutorial_name') AS tutorial_name,
(SELECT ep.value.int_value
FROM UNNEST(event_params) AS ep
WHERE ep.key = 'step_number') AS step_number
FROM `my-project.analytics_123456789.events_*`
WHERE _TABLE_SUFFIX BETWEEN '20240101' AND '20240131'
AND event_name = 'tutorial_step_completed'
ORDER BY event_date, user_pseudo_id;The subquery pattern picks one key out of the array. If you ask for int_value and the parameter was sent as text, you get NULL, with no error. When a query returns nulls for a parameter you know you sent, check the type first. You can also look at all value fields with COALESCE when a parameter's type has changed over time.
Parameter values in BigQuery exist whether or not you registered the parameter in the interface. This makes the export the best place to confirm that collection works.
Common errors
- The parameter is missing in reports. It is likely collected but not registered as a custom dimension or metric. Registration applies going forward. It does not backfill earlier events.
- Different spelling or case across pages.
Tutorial_Nameandtutorial_namebecome two parameters. Define names in one shared spec and reuse it. - Numbers sent as text. A metric such as
step_numberthen cannot be summed. Send numbers as numbers. - Too many unique values. A parameter such as a timestamp or a user-specific ID has near-unlimited distinct values. Reports collapse the long tail into an "(other)" row, and the data becomes hard to use.
- Using parameters for user facts. A plan type sent as an event parameter has to be repeated on every event. A user property is the better tool.
- Parameters on the wrong event. If you attach a parameter to a later event than the action it describes, you cannot join them in a report without extra work.
Testing a parameter end to end
- Send the event from your page or app.
- Open DebugView and confirm the event appears with the parameter and the expected value.
- Register the parameter as a custom dimension or metric if you need it in reports.
- Wait for processing, since new definitions can take a day to show data.
- Check the BigQuery export if enabled, to confirm the stored type.
Exercise
A page sends gtag('event', 'tutorial_step_completed', { step_number: '3' }) in one template and { step_number: 3 } in another. In BigQuery, a query reading ep.value.int_value for step_number returns NULL for some rows. Why does this happen, and how do you fix it?
Show answer
GA4 stores a quoted value as text and an unquoted number as a number, in different fields (string_value and int_value). The first template wrote '3' to string_value, so int_value is NULL for those rows. Fix the template that sends the quoted value so that it sends a number, then keep one type per parameter. For the rows already collected, read both fields, for example with COALESCE(ep.value.int_value, SAFE_CAST(ep.value.string_value AS INT64)).
Exercise
You send a new parameter tutorial_name today and register it as a custom dimension tomorrow. Will last week's events show tutorial_name in standard reports? Where could you still find the earlier values?
Show answer
No. Custom dimension registration applies only to data collected after it is created, so earlier events do not show the value in standard reports. The earlier values can still be found in the BigQuery export, where event_params stores every parameter regardless of registration, provided the export was on when those events were collected.