Sub topic 4
Item parameters in ecommerce events
This chapter covers how GA4 attaches product data to ecommerce events, how custom item parameters become item-scoped custom dimensions, and where this scope behaves differently from event and user scope. It assumes you can read basic JavaScript, you know what an event parameter is, and you know where Admin > Data display > Custom definitions is in a GA4 property.
What an item is
An item is one product (or service) inside an ecommerce event. Items travel in an array called items, which sits next to the normal event parameters. A single purchase event can carry many items, and each item has its own parameters.
GA4 therefore has two levels of detail inside one ecommerce event:
- Event level: values that describe the whole event, such as
currency,value,transaction_idandcoupon. - Item level: values that describe one product, such as
item_id,item_name,priceandquantity.
The same event can carry both levels. The purchase event below is for one order with two products.
gtag('event', 'purchase', {
transaction_id: 'T-1001',
currency: 'USD',
value: 84.97,
items: [
{
item_id: 'SKU_123',
item_name: 'Trail Shoe',
item_brand: 'Ridgeline',
price: 29.99,
quantity: 1,
item_color: 'green'
},
{
item_id: 'SKU_456',
item_name: 'Wool Sock',
item_brand: 'Ridgeline',
price: 12.50,
quantity: 4,
item_color: 'grey'
}
]
});The first four fields in each item are predefined parameters. item_color is not predefined, so it is a custom item parameter.
Predefined item parameters
GA4 already reports a set of item parameters without any registration. Check this list before you create anything custom:
| Parameter | Typical use |
|---|---|
| `item_id`, `item_name` | Product identifier and display name |
| `item_brand` | Brand |
| `item_category` to `item_category5` | Up to five levels of category hierarchy |
| `item_variant` | Variant, such as size or color |
| `item_list_id`, `item_list_name` | The list or placement the product was shown in |
| `price`, `quantity`, `discount` | Numeric item values |
| `coupon`, `affiliation`, `location_id`, `index` | Promotion, supplier, store and list position |
If your data fits one of these, send it there. A color can go in item_variant, and a department can go in item_category. Those fields are already available in the ecommerce reports and do not use up any custom dimension quota. Create a custom item parameter only when no predefined field fits, as with item_color when item_variant already holds the size.
Custom item parameters and item-scoped dimensions
Any extra key you add inside an object in items is a custom item parameter. GA4 collects it, but it stays out of reports until you register it as a custom dimension with Item scope.
The view_item example from the data model chapter shows the pattern:
gtag('event', 'view_item', {
currency: 'USD',
value: 29.99,
items: [{
item_id: 'SKU_123',
item_name: 'Trail Shoe',
item_color: 'green'
}]
});To register item_color:
- Open Admin > Data display > Custom definitions and select Create custom dimension.
- Enter a display name such as
Item color. - Set Scope to Item.
- Enter the exact parameter name,
item_color, in the item parameter field. The name is case sensitive. - Save.
Registration is not retroactive. GA4 starts populating the dimension from the time you save it, so items sent earlier will not have values. Data can also take up to about a day to appear. These are the same rules as for the other scopes.
How item scope differs from event scope
Item scope looks like event scope with the key moved into an array, but the behavior differs in four ways.
The parameter must be inside the item
An event-level item_color and an item-level item_color are different things. This call sends item_color at event level, so an item-scoped dimension will never see it:
gtag('event', 'view_item', {
item_color: 'green', // event parameter, not an item parameter
items: [{ item_id: 'SKU_123' }]
});If the registered item-scoped dimension stays empty, check this first.
Each event type needs its own values
GA4 does not remember an item's custom parameters between events. If you send item_color on view_item but leave it out of add_to_cart and purchase, reports on purchased items will show (not set) for that dimension. Your data layer or ecommerce code should build the item object from one shared product record and reuse it in every ecommerce event.
Reports use item metrics
Item-scoped dimensions are meant to be used with item metrics, such as Items viewed, Items added to cart, Items purchased and Item revenue. They appear in the monetization reports and in Explorations that offer item metrics. If you pair an item-scoped dimension with a metric that has no item context, such as Sessions or a plain event count, the report either hides the combination or returns (not set). In Explorations, the Variables panel marks incompatible fields as unavailable once you select an incompatible one.
The quota is smaller
Standard properties allow far fewer item-scoped custom dimensions than event-scoped ones. At the time of writing, the limit is 10 item-scoped custom dimensions per property, against 50 for event scope. Confirm current numbers in the GA4 documentation before you plan a design, because Google adjusts limits and the 360 tier has higher ones. Because the quota is small, do not register a parameter you have no report for.
Sending item parameters through Google Tag Manager
With Google Tag Manager (GTM), you push an ecommerce object to the data layer and a GA4 event tag reads it. Clear the previous ecommerce object first so stale items do not leak into the next event.
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ ecommerce: null }); // clear the previous object
window.dataLayer.push({
event: 'add_to_cart',
ecommerce: {
currency: 'USD',
value: 29.99,
items: [{
item_id: 'SKU_123',
item_name: 'Trail Shoe',
price: 29.99,
quantity: 1,
item_color: 'green'
}]
}
});In the GA4 event tag, enable Send Ecommerce data and set the source to the data layer. GTM then forwards the whole items array, custom keys included. You do not have to list each custom item parameter in the tag.
Checking the data before you register
Open Admin > DebugView with debug mode on and click the ecommerce event. The items array appears in the event details, and each item shows its parameters. Confirm that:
- The custom key is present inside each item, not only at event level.
- The spelling and case match what you plan to register.
- The values are in a consistent format, such as always
greenand neverGreenorGREEN.
Do this before registration, because a typo you register is a quota slot you cannot reuse for a corrected name without losing history under it.
Querying item-scoped dimensions in the Data API
The Data API uses the customItem: prefix for item-scoped dimensions. Pair them with item metrics:
{
"dateRanges": [{ "startDate": "28daysAgo", "endDate": "today" }],
"dimensions": [
{ "name": "itemName" },
{ "name": "customItem:item_color" }
],
"metrics": [
{ "name": "itemsPurchased" },
{ "name": "itemRevenue" }
]
}The response has one row per combination of item name and color, with the quantity sold and revenue for each. In the BigQuery export, custom item parameters appear in the nested items record, so you read them from the item level of the events table. They do not appear in the top-level event parameters.
Common errors
- Dimension shows
(not set)everywhere: the parameter is at event level, or it is missing from the event type you are reporting on. - Dimension never appears: the parameter name was registered with different spelling or case, or the scope was set to Event instead of Item.
- Old data is blank: registration only applies to data collected after you save it.
- Report rejects the combination: you mixed an item-scoped dimension with a non-item metric.
- Quota reached: a predefined parameter such as
item_variantoritem_category2may already cover the need.
Exercise
Your site sends viewitem and purchase events. You registered an item-scoped custom dimension for itemcolor, but the Items purchased report shows (not set) for it. In DebugView, viewitem shows itemcolor inside each item, while purchase has no item_color at all. What is the problem, and how do you fix it?
Show answer
GA4 does not carry custom item parameters from one event to another. The purchase event never contains itemcolor, so the dimension has no value for purchased items. Fix the purchase code so each item object includes itemcolor, ideally by building items from the same product record used for view_item. Then confirm in DebugView. Purchases already recorded stay (not set), because registration and sending changes are not retroactive.
Exercise
A colleague wants to track each product's "department" as a custom item parameter, with values like Footwear and Socks. What should you check before registering a new item-scoped dimension?
Show answer
Check whether a predefined item parameter already holds this, for example item_category. If it does, send the value there and use the existing report field. Also check how many of the 10 item-scoped slots are already used, make sure the values are a small consistent set, and confirm the parameter is sent inside the items array of every ecommerce event you want to analyze.