Sub topic 4
Event parameters: describing what happened
Assume you know what a GA4 event is and can read basic JavaScript. This chapter focuses on the data attached to an event, not on installing the GA4 tag.
What event parameters are
An event parameter is a key-value pair that adds context to an event. The event name says what happened. Parameters describe details about that occurrence.
For example, add_to_cart identifies a shopping action. Its parameters can identify the product, price, currency, and quantity.
gtag('event', 'add_to_cart', {
currency: 'USD',
value: 29.99,
items: [
{
item_id: 'SKU_123',
item_name: 'Trail Shoe',
price: 29.99,
quantity: 1
}
]
});This event contains the following information:
| Field | Meaning |
|---|---|
| `event_name` | The type of interaction, such as `add_to_cart` |
| `currency` | The currency used for the value |
| `value` | The total value of the event |
| `items` | An array describing one or more products |
Parameters belong to a particular event occurrence. If a visitor adds two different products, each add_to_cart event can have different parameter values.
Standard and custom parameters
GA4 recognizes parameters for recommended events. For example, currency, value, and items have expected meanings for ecommerce events. Using the documented names allows GA4 reports and ecommerce features to interpret the data correctly.
A custom parameter is a parameter name that you define for your own event. For example:
gtag('event', 'tutorial_step_completed', {
step_number: 3,
tutorial_name: 'ga4_data_model'
});GA4 can collect these values immediately. However, sending a parameter does not automatically make it available as a selectable field in standard reports. To use step_number or tutorial_name in reports and explorations, register the appropriate custom definition in the GA4 interface.
Choose parameter names that describe one fact clearly. Use stable names such as plan_type or content_group. Avoid putting several facts into one text value, such as premium_member_from_email.
Parameter values and scope
A parameter should describe the event being sent. For example, search_term belongs on a search event, while button_text might belong on a button-click event.
Use a custom dimension for descriptive text or categories, such as tutorial_name. Use a custom metric for numeric measurements that you want to aggregate, such as step_number or download_size. The correct choice depends on how you plan to analyze the value.
Do not confuse an event parameter with a user property. An event parameter describes one action. A user property describes an attribute of the user across multiple events. A visitor's plan_type is usually a user property, while the plan_type selected during one checkout event may be an event parameter.
How parameters flow through GA4
Common mistakes include misspelling a recommended parameter, changing the meaning of a parameter over time, and sending numbers as inconsistent text values. Validate the event in DebugView before relying on it in reports. Also check that the parameter is present on every relevant event, not only on one code path.
Exercise
You send tutorial_step_completed with step_number: 3, but cannot select step_number in a standard report. What is the likely cause?
Show answer
The parameter is being collected but has not been registered as a custom dimension or metric. Register it with the scope and type that match how you want to analyze it.