Sub topic 5
Choosing a scope: event, user or item
This chapter assumes you know what a GA4 event is, can find Admin and the property's data streams, and can read basic gtag.js or Google Tag Manager (GTM) code. You will learn how to pick the scope of a custom dimension before you register it. The scope is the part of the data model the value describes: one event, one user, or one product in an ecommerce event.
Why scope matters
A custom dimension is a name you add to reports. It reads a value that you already send with your data. You must choose one of three scopes when you register it. The scope tells GA4 where to look for the value.
The choice is hard to undo. Once a custom dimension is registered, you cannot edit its scope. To fix a wrong scope you register a new dimension and archive the old one. Data collected under the old registration does not move to the new one. So decide before you register.
The three scopes match the three places where GA4 stores extra data.
| Scope | Where the value comes from | What it describes | Typical example |
|---|---|---|---|
| Event | An event parameter | One specific event | `plan_tier` on a `select_plan` event |
| User | A user property | The person across events | `customer_type` set to `subscriber` |
| Item | A custom parameter inside `items` | One product in an ecommerce event | `item_color` on a `view_item` event |
Event scope: describing what happened
Use event scope when the value belongs to a single action and can differ the next time the same action happens. A person can choose the pro plan today and the basic plan tomorrow. Each event carries its own value.
gtag('event', 'select_plan', {
plan_tier: 'pro',
billing_cycle: 'annual'
});Here plan_tier and billing_cycle are event parameters. After you register them as event-scoped custom dimensions, reports can break down select_plan events by either one.
Event scope is the safest default. It never guesses about the user. It reports exactly what was on the event.
User scope: describing who did it
Use user scope when the value describes the person and stays true across many events. Plan type, customer status, and preferred language are examples. You set it once, and GA4 attaches it to later events from that user.
gtag('set', 'user_properties', {
customer_type: 'subscriber'
});The value customer_type is a user property. After you register it as a user-scoped custom dimension, you can compare behavior of subscribers and non-subscribers across any report.
User scope has a few behaviors that surprise people.
- The value is attached to events that happen after you set it. Earlier events do not get it.
- The newest value wins. If a user changes from
trialtosubscriber, new events carrysubscriber. - In reports, a user-scoped value applies to the events that carry it. A user who changes value can appear under both values over a date range.
- You must set the property again on a new page load if your code does not persist it. In gtag.js the value stays only for the current page unless GA4 has stored it from an earlier visit. Setting it on every page load, as soon as you know it, is the reliable approach.
Item scope: describing a product
Use item scope when the value describes a product inside an ecommerce event. Several products can sit in one event, and each can have a different value. Event scope cannot express that, because one event parameter gives one value to the whole event.
gtag('event', 'view_item', {
currency: 'USD',
value: 29.99,
items: [{
item_id: 'SKU_123',
item_name: 'Trail Shoe',
item_color: 'green'
}]
});In this call item_id and item_name are standard item parameters. item_color is a custom item parameter. After you register item_color as an item-scoped custom dimension, item reports can split sales and views by color.
Item scope only works with events that carry an items array, such as view_item, add_to_cart and purchase. A value in an items array does not show up in non-ecommerce reports, and it does not work as an event parameter.
A decision process
Ask these questions in order.
- Does the value live inside an
itemsarray, with one value per product? Choose item scope. - Is the value about the person, and will it stay true across many events? Choose user scope.
- Otherwise, the value describes this one event. Choose event scope.
Test the choice with one more question. Imagine the same user doing the same action twice, at different times. If the value could be different each time, it is not a user property. If two products in one event could have different values, it is not an event parameter.
Common mistakes
Putting a user attribute on an event
Suppose you send customer_type as an event parameter only on a login event. Later events do not carry it. A report on purchase events cannot split by customer type. If you want that split everywhere, set a user property instead.
Using a user property for something that changes per action
Suppose you store the last plan the user selected as a user property. It then describes every later event, including ones unrelated to plans. The report becomes misleading, because it shows the latest value rather than the value at that moment. Use an event parameter for per-action values.
Using an event parameter for per-product values
If a cart event holds a basket of three products, one color parameter on the event cannot describe three colors. Put item_color inside each item and register an item-scoped dimension.
Expecting scopes to be interchangeable
The same name can exist at different scopes, but each registration is independent. If you send plan_tier as both an event parameter and a user property, you register two dimensions, one for each scope. A report that uses the event-scoped one does not read the user property.
Scope and the Data API
Scope also shows up when you query the data with the Data API. The prefix on the dimension name tells GA4 which scope to read.
{
"dateRanges": [{ "startDate": "28daysAgo", "endDate": "today" }],
"dimensions": [{ "name": "customEvent:plan_tier" }],
"metrics": [{ "name": "eventCount" }]
}The prefix customEvent: reads an event-scoped dimension. User-scoped dimensions use customUser: and item-scoped dimensions use customItem:. If you pick the wrong prefix, the request fails or returns nothing, so the scope you chose at registration controls how you query later.
| Scope | Data API prefix | Example name |
|---|---|---|
| Event | `customEvent:` | `customEvent:plan_tier` |
| User | `customUser:` | `customUser:customer_type` |
| Item | `customItem:` | `customItem:item_color` |
Metrics are event-scoped
Custom metrics are different from dimensions. A custom metric holds a number, and it is event-scoped. There is no user scope or item scope for metrics. You send a numeric event parameter, and you register it as a custom metric.
In GTM you might push a number like this.
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'video_complete',
video_length_seconds: 184
});A GA4 event tag in GTM can map video_length_seconds to an event parameter. You then register that parameter as a custom metric. A later chapter covers units of measurement and registration in detail. For now, remember that the number comes from the event, so the metric is tied to event scope.
Practical checks before you register
- Write down the parameter or property name, its scope, and an example value.
- Confirm the value is already being sent. DebugView, covered in the next chapter, shows this.
- Check that the name matches exactly. Names are case-sensitive, so
Plan_Tierandplan_tierare different. - Confirm you have room in the property's quota for your scope. Each scope has its own limit.
- Keep personal data out of the value. Do not send emails, names or phone numbers.
Summary of the choice
- Choose event scope for facts about one action.
- Choose user scope for traits of the person that persist.
- Choose item scope for per-product details inside ecommerce events.
- Remember that custom metrics are event-scoped numbers.
Exercise
Your store sends a purchase event with three products in items. Each product has its own item_brand value. Which scope should the custom dimension for item_brand use, and why would event scope fail?
Show answer
Use item scope. Each product in the items array has its own value, and an item-scoped dimension reads the value per item. An event parameter holds one value for the whole event, so it could not represent three different brands in one purchase.
Exercise
You set gtag('set', 'user_properties', { customer_type: 'subscriber' }); and register customer_type as an event-scoped dimension. A report on purchase events shows no values. What went wrong, and what is the fix?
Show answer
customer_type is sent as a user property, but it was registered with event scope, so GA4 looks for an event parameter with that name and finds none. Register a new custom dimension with user scope for customer_type, and archive the event-scoped one. Data collected before the new registration is not filled in.