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.

Subscribe to keep reading & get free access to GA4 Mastery Course

This content is free, but you must be subscribed to OptimizeSmart Newsletter to continue reading.

I consent to receive newsletters via email. Terms of Use and Privacy Policy.

Already a subscriber?Sign In.Not now