Sub topic 7
User properties: describing who did it
Prerequisites: You should understand that GA4 records interactions as events and that event parameters describe each event. You should also be comfortable reading basic JavaScript.
A user property is an attribute associated with a user. It describes a relatively stable fact about the person, such as their plan type, preferred language, or customer tier. An event parameter describes one occurrence, such as the value of a purchase. The same user property can be associated with many events from that user.
For example, plan_type describes the user, while item_id describes a product in one purchase:
| Data | Scope | Example |
|---|---|---|
| User property | User | `plan_type = "premium"` |
| Event parameter | One event | `value = 29.99` |
Setting a user property
With gtag.js, set a user property using the user_properties object:
// Set a user property for subsequent events
gtag('set', 'user_properties', {
plan_type: 'premium'
});
// Configure GA4 for a signed-in user
gtag('config', 'G-XXXXXXXXXX', {
user_id: 'u_12345'
});After GA4 receives this setting, the property is associated with subsequent events from that user. It does not rewrite earlier events. If the user changes from a free plan to a premium plan, send the new value. Events collected after the change can then have the new value.
The property value should represent the current state you intend to analyze. For example, use plan_type: 'premium', not a sentence such as customer upgraded recently. Use a separate event, such as an upgrade event, to record when a change happened.
Scope and reporting
User properties have user scope. When you use one in an analysis, GA4 can group or filter activity by the value associated with the user. This differs from an event-scoped value, which belongs only to the event that carried it.
A custom user property is collected when you send it, but it may not immediately appear as a selectable field in standard reports. Register it in the GA4 property as a custom dimension. Choose a user-scoped dimension for values such as plan_type. Registration makes the field available to supported reports and explorations. It does not add the property to events that were collected before the property was set.
The same user can use multiple devices or browsers. A user property is only as consistent as GA4's ability to recognize that activity as belonging to the same user. Signed-in systems can improve continuity by sending a stable, non-personally identifying User-ID after authentication. Follow your organization's consent and privacy rules before sending identity-related data.
How the value moves through GA4
Common errors
- Setting a user property only on a purchase page, then expecting it to describe all earlier activity.
- Using an event parameter when the value should describe the user across many events.
- Changing the property name or spelling, creating multiple fields such as
plan_typeandplanType. - Registering a property after collection and expecting historical events to gain the missing value.
- Sending personal information instead of an internal category or approved identifier.
Exercise
A visitor upgrades from free to premium. Should you change the existing purchase event, or send the new user property for later events?
Show answer
Send the new plan_type value for later events and record the upgrade as its own event if you need to analyze when the change occurred.