String in uppercase
1 2 3 4 5 | var StringLowerCase = “{{String in lowercase}}”;var StringUpperCase = StringLowerCase.toUpperCase();return StringUpperCase;} |
This article is from our archive and reflects the situation as of March 2022.
Custom variables (especially Custom JavaScript Variables) of Google Tag Manager are a powerful tool to eliminate tracking issues. A variable of the Custom JavaScript type consists of an anonymous function that returns a value. Custom JavaScript Variables often use other Tag Manager variables as input and return a modified version of that as output.
In simple terms, a custom JavaScript variable takes other variables as input, processes them with JavaScript and returns the result as a new variable.
A small list of additional variables for use in GTM
1 2 3 4 5 | var StringLowerCase = “{{String in lowercase}}”;var StringUpperCase = StringLowerCase.toUpperCase();return StringUpperCase;} |
1 2 3 4 5 | var StringUpperCase = “{{String in uppercase}}”;var StringLowerCase = StringUpperCase.toLowerCase();return StringLowerCase;} |
1 2 3 4 5 | var StringInclSpecialChars = “{{String with special characters}}”;var StringExclSpecialChars = StringInclSpecialChars.replace(/[^A-Za-z0-9_]/g, ”);return StringExclSpecialChars;} |
1 2 3 4 5 6 7 8 9 10 | {var StringInclUmlaute = “{{String with umlauts}}”;var LowerCaseIncUmlaute = StringInclUmlaute.toLowerCase();var LowerCaseExcUmlaute = LowerCaseIncUmlaute.replace(/ä/g, ‘ae’);LowerCaseExcUmlaute = LowerCaseExcUmlaute.replace(/ö/g, ‘oe’);LowerCaseExcUmlaute = LowerCaseExcUmlaute.replace(/ü/g, ‘ue’);LowerCaseExcUmlaute = LowerCaseExcUmlaute.replace(/ß/g, ‘ss’);return LowerCaseExcUmlaute;} |