Google Tag Manager can format and transform the returned value of a user-defined web variable. This feature can help normalize values that are sent to your tags and reports, and reduce the need to create contingencies for situations where values need to be consistent.
To use this feature click Format Value at the bottom of any user-defined web variable page and select one or more options:
- Change Case to… (lowercase or uppercase)
- Convert to number
- Convert null to… (text or variable)
- Convert undefined to… (text or variable)
- Convert to true/false
- Convert true to… (text or variable)
- Convert false to… (text or variable)
- Convert to number(variable)
- Convert to true/false(variable)
If multiple options are selected, they will take effect in the order shown from top to bottom.
Convert to number
When converting to a number, you must choose a decimal separator:
- Period (.): A period denotes the decimal place. All other non-numeric characters will be ignored.
Examples: '123.456' will be converted to 123.456 and '111,222' will be converted to 111222.
- Comma (,): A comma denotes the decimal place. All other non-numeric characters will be ignored.
Examples: '123.456' will be converted to 123456 and '111,222' will be converted to 111.222.
- Automatic (currency): The decimal separator will be automatically detected, allowing the same variable to support both period and comma decimal separators. This option assumes the number is a currency value, so if there are exactly three digits after the separator, the separator will not be treated as a decimal.
Examples: '123.45' and '123,45' will both be converted to 123.45. '111,222' and '111.222' will both be converted to 111222.