Sub topic 12
Custom events and custom dimensions
Assume you have a GA4 property with a web data stream, basic familiarity with the GA4 interface, and a page that already loads gtag.js. This chapter uses an event-scoped custom dimension. An event-scoped custom dimension describes a value attached to an event.
Add business context with a custom event
GA4 collects activity as events. Standard events such as page_view and scroll cover common interactions, but a business often needs more specific events. A custom event is an event that you define for your own measurement needs.
For example, a newsletter form can send an event named newsletter_signup. The placement parameter records where the form appeared:
// Send this after the newsletter form is successfully submitted.
gtag('event', 'newsletter_signup', {
placement: 'footer'
});The event name identifies the action. The parameter adds context to that action. If the same event occurs in a header, you can send placement: 'header'.
Choose names that describe actions clearly. Use lowercase names and underscores, and avoid creating a custom event when GA4 already provides a suitable automatically collected, enhanced measurement, or recommended event. Consistent names make reports easier to understand.
Register the parameter as a custom dimension
After sending the event, register placement in the GA4 interface:
- Open Admin for the property.
- Select Data display > Custom definitions.
- Select Create custom dimension.
- Enter a display name such as
Form placement. - Choose Event as the scope.
- Enter the event parameter name exactly as sent:
placement. - Save the definition.
The parameter name is case-sensitive in practice. placement, Placement, and form_placement are different names. Register the name that your implementation actually sends.
Registration affects future reporting. It does not transform old collected data into the new dimension. Allow time for new values to appear in standard reports. You can inspect incoming values sooner with DebugView while testing.
The distinction between an event parameter and a custom dimension is useful:
| Item | Purpose |
|---|---|
| Event parameter | Carries context with an individual event |
| Custom dimension | Makes a parameter available for grouping and filtering reports |
Follow the data path
The following path shows how one interaction becomes a reportable breakdown.
In an Engagement report, you can use the event name to find newsletter_signup and examine its event count. After registration, you can break down the event by Form placement, such as header or footer. An event can be useful without any custom dimension, but the dimension lets you compare contexts.
Test and avoid common mistakes
Use DebugView to confirm that the event arrives and that the parameter has the expected value. Test the successful action, not only a button click, so failed submissions do not inflate the count.
Common mistakes include:
- Sending a different parameter name from the one registered.
- Registering a dimension after collecting data and expecting historical rows to change.
- Using many nearly identical event names instead of one event with a descriptive parameter.
- Sending personally identifiable information, such as an email address, in an event parameter.
- Treating a parameter as a metric. A value such as
placementis a category, while a count of events is a metric.
Exercise
You send newsletter_signup with a placement parameter, but the Events report shows the event without a placement breakdown. What should you check first?
Show answer
Confirm that the parameter name matches exactly, then register it as an event-scoped custom dimension. Also verify the value in DebugView and remember that registration does not populate historical data.