Overview
You can set up custom dimensions and metrics that get their values from the event parameters that you collect for your property.
Example
You collect the following event each time a visitor to your website reads an article:
gtag('event','read_article', {
"author":"Bill Q",
"title":"How to Build a Backpack",
"number_of_pages":2,
});
You can create an Author dimension that gets its values from the author
parameter and an Article_Length metric that gets its value from the number_of_pages
parameter.
Best practices
Before you set up custom dimensions and metrics, you should take full advantage of the dimensions and metrics collected through automatically collected events, enhanced measurement events, and recommended events.
If you have a standard property, avoid creating high-cardinality custom dimensions. High-cardinality dimensions are dimensions with more than 500 unique values per day. These dimensions may negatively impact your reports and cause data to aggregate under the (other) row. For example, for a high-cardinality dimension like User ID (i.e., when you want to collect an ID for each distinct user), use the User-ID feature.
Event and user scope
You can configure your custom dimensions to be either event-scoped or user-scoped.
- Event scope: In the previous example, you would create the Author dimension using event scope.
- User scope: You can create user-scoped custom dimensions to identify static or slowly changing attributes of your users, such as "spender=true", "profession=engineer", or "favorite_team=Real Madrid".
You must always use event scope for custom metrics.
Limits
When creating custom dimensions and metrics, consider the following limits for Google Analytics and Google Analytics 360 properties:
Item | Standard property limits | 360 property limits |
---|---|---|
Event-scoped custom dimensions | 50 | 125 |
User-scoped custom dimensions | 25 | 100 |
Custom metrics | 50 | 125 |
If you reach your quota and need to create more custom dimensions or metrics, archive the ones you're no longer using.
To see the total number of custom dimensions and metrics you've created, go to Configure > Custom definitions in the left navigation and then click Quota information on the top right.
Create a custom dimension
- In the left navigation, click Configure > Custom definitions.
- Click Create custom dimensions.
- Enter a Dimension name. You can't use hyphens in the dimension name; however, you can use underscores or spaces instead.
- Select a Scope from the drop-down menu (Event or User).
- Enter a Description for your custom dimension.
- Select an Event parameter (event scope) or User property (user scope) from the list or enter the name of a parameter/property you'll collect in the future.
- Click Save.
Create a custom metric
- In the left navigation, click Configure > Custom definitions.
- Click Create custom metrics.
- Enter a Metric name. You can't use hyphens in the metric name; however, you can use underscores or spaces instead.
- Enter a Description for your custom metric.
- Select an Event parameter from the list or enter the name of a parameter you'll collect in the future.
- Choose a Unit of measurement from the drop-down menu.
When you select Currency as the unit of measurement, you must also identify the custom metric as a cost and/or revenue metric under Data type. When you identify the custom metric as a cost and/or revenue metric, you can restrict access to it when you configure user roles that restrict access to cost and/or revenue metrics.
- Click Save.
Edit a custom dimension or metric
- In the left navigation, click Configure > Custom definitions.
- In the row for the dimension or metric, click
, then click Edit.
- Make the changes you want, then click Save.
Archive a custom dimension or metric
If you need to create new custom dimensions and/or metrics but you have reached your quota limit, you can archive ones you are no longer using in order to free up space.
Archiving a custom dimension or metric affects any audiences, explorations, or segments that are based on that dimension or metric.
- In the left navigation, click Configure > Custom definitions.
- In the row for the dimension or metric, click
, then Archive.
A list of the other entities in Analytics (e.g., audiences, explorations) that use the custom definition will appear.
When you archive a custom dimension or metric that is used in the definition of an audience, that audience definition becomes invalid and the audience doesn't accumulate any new users.
Historical data for the audience is preserved, but no new data is generated once the audience becomes invalid.
You can't export invalid audiences to other products (e.g., Google Ads, Google Optimize).
If you've previously exported the audience to other products, the audience will continue to function as expected. However, since the audience is not accumulating new users, the user count will drop as the membership duration expires for existing users until the audience contains no users.
If an audience includes an archived custom dimension or metric, you see a warning icon next to the audience name in the audience list:
When you edit the audience definition, you see an additional message that the audience includes an archived custom dimension or metric:
Warning icons similar to the ones for archived audiences appear in Explorations for explorations or segments that include archived custom dimensions or metrics. In addition, the dimension and metric lists in Explorations identify archived custom definitions with a warning icon.
As with audiences, explorations and segments with archived custom definitions are invalid and will not load.
If you remove the archived custom definition, then the exploration or segment will load.
While archived custom definitions appear in the dimension and metric lists (with a warning), you can't add them to explorations or segments.
Deprecation of custom-parameter reporting
With event-scoped custom dimensions and metrics, parameters are identified for property-wide dimensions and metrics, allowing you to create a single dimension or metric based on a parameter and report on it for as many events as you wish. Previously with custom-parameter reporting, parameters were identified for individual events. Consequently, if you wanted to report on the same parameter for five different events, you had to use five of your quota of 100 custom dimensions and metrics.
With the deprecation of custom-parameter reporting, Analytics has preserved historical event-scoped aggregates, and new aggregates seamlessly extend that historical data. In cases where a parameter was registered for multiple events, Analytics disambiguates between them by assigning a dimension/metric name that includes the currently assigned event name (e.g., “custom_dimension_name [event_name]”).
As a best practice, you should remove duplicate custom dimensions and metrics that were registered across multiple events to help preserve your quota.
User-scoped custom dimensions eliminate the need for you to think about "slots". User properties become aliases for user-scoped custom dimension slots, allowing developers to focus on tracking meaningfully named data points without having to associate each data point with an arbitrary slot number.