Sub topic 1
How GA4 Models Events and Parameters
Prerequisites
You should know how to open a GA4 property and its data streams. You should also read basic JavaScript objects and arrays, and understand how a web shop's product, cart, and checkout pages work. Basic JSON familiarity helps when you read payloads.
Events and Parameters
Google Analytics 4 (GA4) records every tracked action as an event. An event is a named record of something that happened, such as a page view or a purchase. Each event has a name, like add_to_cart, and zero or more parameters. A parameter is a key-value pair that adds detail, such as currency or value.
Event and parameter names use lowercase letters, digits, and underscores. Names are case-sensitive, so Purchase and purchase are different events.
The Recommended E-commerce Events and the Shopping Funnel
Google recommends a standard set of e-commerce event names. They follow the shopping funnel from browsing to purchase. Using these names lets GA4 fill its standard e-commerce reports without custom setup.
The Items Array: Describing Products in an Event
E-commerce events carry an items array, which is a list of objects. Each object describes one product line. A cart with two pairs of the same shoe sends one item object with quantity: 2, not two objects. One event can hold several different products in the array.
Item Parameters: IDs, Names, Prices, Quantities, and Categories
Common item parameters include item_id, item_name, item_brand, item_category, item_variant, price, and quantity. Send at least item_id or item_name for each item. The price field is the unit price, not the line total.
gtag('event', 'view_item', {
currency: 'USD',
value: 24.99,
items: [
{
item_id: 'SKU_1001',
item_name: 'Trail Running Shoe',
item_brand: 'Acme',
item_category: 'Shoes',
item_variant: 'blue',
price: 24.99,
quantity: 1
}
]
});Currency and Value: Getting Money Fields Right
The currency parameter takes a three-letter ISO 4217 code, such as USD or EUR. The value parameter takes a number that is the total for the event. Do not include currency symbols or thousands separators.
For add_to_cart, value should equal the sum of price times quantity across all items.
Exercise
A cart holds two shirts at 15.00 each and one hat at 10.00. Which currency and value should the addtocart event send, assuming USD?
Show answer
currency: 'USD' and value: 40.00, because 2 × 15.00 + 1 × 10.00 = 40.00. The shirt item uses quantity: 2 and price: 15.00, and the hat item uses quantity: 1 and price: 10.00.