Sub topic 1
How GA4 models events, parameters and users
Custom dimensions and custom metrics in GA4 only make sense once you know what GA4 stores. This chapter describes the data model: what an event contains, where parameters and user properties sit, and why the model leads to three custom dimension scopes. Later chapters cover sending, registering and reporting.
Prerequisites
This chapter assumes you:
- Can find reports, Admin, properties and data streams in the GA4 interface.
- Know that GA4 is event-based and can name a few events, such as
page_vieworpurchase. - Can read short JavaScript snippets. You don't need to write them yet. Google Tag Manager (GTM) experience also helps.
Everything is an event
Earlier Google Analytics versions had separate hit types: pageviews, events, transactions and social interactions. GA4 has one record type, the event. A page load, a scroll, a purchase and a video completion are all events.
Each event record carries:
- An event name, such as
page_vieworselect_plan. - A timestamp.
- Event parameters: key-value pairs that describe this occurrence.
- User properties: key-value pairs that describe the person or device, attached to every event they send.
- An optional
itemsarray for ecommerce events, where each item has its own fields. - Identifiers, such as the client ID, the optional User-ID and the session ID, which let GA4 group events into users and sessions.
Sessions are not stored as separate objects. GA4 builds them from the session_start event and the ga_session_id parameter on each event. Users are likewise derived from identifiers on events.
GA4 sorts event names by origin:
| Category | Who defines the name | Examples |
|---|---|---|
| Automatically collected | Google, always on | `first_visit`, `session_start`, `user_engagement` |
| Enhanced measurement | Google, toggled in the data stream settings | `scroll`, `click` (outbound), `file_download` |
| Recommended | Google defines name and parameters, you implement them | `login`, `purchase`, `add_to_cart` |
| Custom | You | `select_plan`, `video_complete`, `offline_sale` |
Using a recommended name where one fits gives you built-in report support. Custom events carry meaning only for you, so you will need to register their parameters to see them in reports.
The structure of an event
The diagram shows how the pieces relate.
The model has two directions. Events and their parameters describe individual occurrences, and each event is its own record. User properties describe the user and are carried along with the events that user sends afterwards.
Event parameters
An event parameter is a key-value pair attached to one event. Parameters answer questions such as which page, which plan, which button or how much.
GA4 collects some parameters automatically. Examples are page_location, page_referrer, page_title, ga_session_id and engagement_time_msec. Recommended events define more, such as currency and value for purchase. You can also add your own, as in this call:
gtag('event', 'select_plan', {
plan_tier: 'pro',
billing_cycle: 'annual'
});Here select_plan is a custom event. plan_tier and billing_cycle are custom parameters. Both values belong only to this event.
Four properties of parameters matter for what follows:
- They are scoped to the event. The same parameter name on a different event is a separate value. Setting
plan_tieronselect_plandoes not add it topage_view. - They are collected but not automatically reportable. The raw value is stored with the event. Standard reports and Explorations only show the parameters Google has built in, plus the ones you register.
- They hold text or numbers. A string such as
'pro'suits a dimension. A number such as184can serve as a metric after registration. - They have limits. On standard properties, an event can carry up to 25 custom parameters, and a parameter value can be up to 100 characters. Limits are covered in a later chapter.
User properties
A user property is a key-value pair that describes the user rather than a single action. Examples are a subscription status, a preferred language or a customer segment. You set it once, and GA4 attaches it to later events from that user.
gtag('set', 'user_properties', {
customer_type: 'subscriber'
});Some points to know:
- Persistence. A user property keeps its value until you overwrite it. Each new event from that user carries the current value.
- Time of capture. Each event stores the property value at the moment the event was sent. If
customer_typechanges fromtrialtosubscriberon Tuesday, earlier events keeptrial. This matters when you analyze events across a status change. - Reporting. As with event parameters, user properties are not shown in reports until you register them.
- Limits. On standard properties, a property can hold up to 25 user properties, and each value is limited to 36 characters.
- Names to avoid. GA4 reserves some names, including those that start with
google_,ga_orfirebase_.
User properties are not the same as the automatically collected user-level attributes that GA4 reports, such as country or device category. Those are built-in dimensions.
Item parameters
Ecommerce events such as view_item, add_to_cart and purchase can include an items array. Each element describes one product. GA4 defines standard item fields, including item_id, item_name, item_brand, item_category, price and quantity. You can add your own fields on the same object.
gtag('event', 'view_item', {
currency: 'USD',
value: 29.99,
items: [{
item_id: 'SKU_123',
item_name: 'Trail Shoe',
item_color: 'green'
}]
});In this call, currency and value are event parameters. item_id and item_name are standard item fields. item_color is a custom item parameter. Item data differs from event data because one event can hold many items, each with a different item_color. A value for the whole event cannot describe each item, so GA4 gives item parameters their own scope.
Why registration is needed
Collection and reporting are separate steps in GA4. Events arrive with their full set of parameters, but the reporting layer exposes only a defined set of fields. To use your own parameter as a dimension in reports, you register it in Admin, where it becomes a custom dimension. For a numeric parameter you want to sum or average, you register a custom metric.
The three kinds of source data map to three dimension scopes:
| Source | Custom definition | Scope | What each value describes |
|---|---|---|---|
| Event parameter | Custom dimension | Event | One event |
| User property | Custom dimension | User | A user, across their events |
| Item parameter | Custom dimension | Item | One product within an event |
| Numeric event parameter | Custom metric | Event | A number measured on an event |
Custom metrics are event-scoped only. Choosing the scope is a design decision you make before registering. Registering the same field under the wrong scope produces wrong or empty reports, and you cannot change a definition's scope afterwards without creating a new one.
Dimensions and metrics
The words dimension and metric appear throughout GA4:
- A dimension is an attribute you group or filter by. Examples are
Page path,Countryand, once registered,plan_tier. Dimensions are usually text. - A metric is a number you aggregate. Examples are
Event count,SessionsandTotal revenue. A registered custom metric lets you sum or average a numeric parameter.
A report is a table where dimensions form the rows and metrics fill the columns. If a parameter you want is not available as a dimension, the likely cause is that it is not registered.
A worked example
A SaaS site wants to know which pricing plan visitors pick and whether subscribers behave differently. It sends this when a visitor selects a plan:
gtag('set', 'user_properties', {
customer_type: 'subscriber'
});
gtag('event', 'select_plan', {
plan_tier: 'pro',
billing_cycle: 'annual'
});GA4 stores one select_plan event. It has two event parameters and carries one user property. Nothing appears in reports yet. To see the data, the team needs to:
- Register
plan_tierandbilling_cycleas event-scoped custom dimensions. - Register
customer_typeas a user-scoped custom dimension. - Wait for processing, then build a report or Exploration with
plan_tieras the dimension andEvent countas the metric.
Those steps are covered in the next chapters.
Summary of the model
- GA4 has one record type, the event. It carries a name, parameters, user properties and, for ecommerce, items.
- Event parameters describe an occurrence, user properties describe the user, and item parameters describe a product within an event.
- GA4 collects all three, but reports show only built-in fields and those you register.
- Registration produces custom dimensions in event, user or item scope, plus event-scoped custom metrics.
Exercise
A page sends the call gtag('event', 'addtocart', { currency: 'USD', value: 59, items: [{ itemid: 'SKU9', itemname: 'Rain Jacket', itemsize: 'M' }] }). Which of currency, itemid and itemsize are event parameters, and which is a custom item parameter?
Show answer
currency and value are event parameters. itemid and itemname are standard item fields, and itemsize is the custom item parameter, because it sits inside the items array and is not part of the GA4 standard item fields. All of them travel on one addtocart event, but only itemsize would need an item-scoped custom dimension to appear as a dimension in reports.
Exercise
A user is a trial customer on Monday, so customertype is 'trial'. On Tuesday they subscribe and you set customertype to 'subscriber'. What value does an event sent on Monday carry, and why does this matter when analyzing across the change?
Show answer
The Monday event keeps 'trial'. GA4 stores the user property value on each event at the time it is sent, so later changes do not rewrite earlier events. When you report on customer_type across the change, the same person appears under both values, depending on the date of the event.
Exercise
You send a custom parameter coupon_code on a purchase event today. Next week you register it as a custom dimension. Will events from today appear with that dimension in reports?
Show answer
No. Registration is not retroactive, so only events that arrive after the registration populate the custom dimension in reports. The raw parameter from today's events remains in the stored data, but standard reports and Explorations will not show it.