Sub topic 6
Sending Parameters and User Properties
Assume you know that GA4 collects events and that you can work with basic JavaScript or Google Tag Manager (GTM). This chapter shows how to attach extra values to events and users. You should validate the values in DebugView before registering them as custom definitions.
Choose what to send
An event parameter describes one occurrence. For example, plan_tier can describe the plan selected during a select_plan event.
A user property describes the user across later events. For example, customer_type can identify a subscriber. GA4 attaches the property to future events from that user. It does not describe only one action.
An item parameter describes one product inside an ecommerce event. Put it inside the event's items array rather than beside the other event parameters.
| Data type | Example | Where it belongs |
|---|---|---|
| Event parameter | `plan_tier: "pro"` | The event's parameter object |
| User property | `customer_type: "subscriber"` | The user's property collection |
| Item parameter | `item_color: "green"` | An object in the `items` array |
Send data with gtag.js
The Google tag must already be installed and configured for the property. Then use gtag('event', ...) to send an event and its parameters:
gtag('event', 'select_plan', {
plan_tier: 'pro',
billing_cycle: 'annual'
});Parameter names should describe the value clearly. Use stable names and consistent value formats. For example, always send annual rather than sometimes sending yearly.
Set a user property when your application knows something about the user:
gtag('set', 'user_properties', {
customer_type: 'subscriber'
});This setting affects later events from the browser or app context. Set the property again when its value changes. Do not send names, email addresses, phone numbers, or other personally identifiable information (PII).
For ecommerce data, place custom item parameters inside items:
gtag('event', 'view_item', {
currency: 'USD',
value: 29.99,
items: [{
item_id: 'SKU_123',
item_name: 'Trail Shoe',
item_color: 'green'
}]
});item_color belongs to the product, so it can later become an item-scoped custom dimension. A value such as checkout_method would usually belong at event scope because it describes the checkout event.
Send data through Google Tag Manager
With GTM, application code can push an object to the data layer. The data layer is a shared queue of values that GTM reads:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'video_complete',
video_length_seconds: 184
});Create a data-layer variable named video_length_seconds in GTM. In a GA4 Event tag, use video_complete as the event name and map that variable to the video_length_seconds event parameter. Because the value is numeric and measures duration, it may later be registered as a custom metric with a time-related unit.
For a user property, create a user-property field in the relevant GA4 configuration or event tag and map it to a data-layer variable. Keep the mapping documented so later changes do not alter the meaning of the property.
Send server-side events
The Measurement Protocol lets a server send events directly to GA4. A request body can include custom parameters:
{
"client_id": "555.1234567890",
"events": [
{
"name": "offline_sale",
"params": {
"store_region": "north",
"basket_size": 4
}
}
]
}The server request also requires the correct Measurement Protocol endpoint and credentials for the data stream. Protect the API secret on the server. Never place it in browser code.
Validate before registration
Use a test device or browser session, send the event, and open DebugView. Check the event name, parameter names, value types, and item structure. A parameter sent as text in one implementation and as a number in another can produce confusing reports.
Exercise
A select_plan event includes customer_type: "subscriber". Should customer_type be an event parameter or a user property if it describes the customer's account for future events?
Show answer
Send it as a user property. Use an event parameter only when the value describes that particular plan-selection event.