- OptimizeSmart Newsletter
- Posts
- How to Force GA4 to Recognize Numbers in Custom Dimensions
How to Force GA4 to Recognize Numbers in Custom Dimensions
π Here is how you can force GA4 to treat numerical values of a custom dimension as numbers and not strings. π
In GA4, the values of all custom dimensions are stored and processed as strings, even if the original data you are sending is a number, date, boolean, or any other data type.
Because all values are treated as strings, this can affect how data is sorted or analyzed in GA4 reports.
Numerical values sorted alphabetically (as strings) will be out of order.
For example,
β10β would appear before β2β because β1β comes before β2β alphabetically.
Filtering and calculations involving numbers might not work as expected.
For example,
Filtering for βitem ID greater than 100β would also include β2,β β20,β β30,β etc., because these strings come after β100β alphabetically.
In alphabetical order:
β2β comes after β100β because β2β is greater than β1β.
β20β comes after β100β because β2β is greater than β1β.
β30β comes after β100β because β3β is greater than β1β.
Even though these IDs are numerically less than 100, they will be included in the filter results.