#GTMTips: Format option value in Google Tag Manager Variables – News Couple

#GTMTips: Format option value in Google Tag Manager Variables

A very recent addition to Google Tag Manager is Format value Option on all GTM variants. With the format value, you can modify the output of a variable with a number of predefined transformations.

This is very useful, because you no longer need to create custom JavaScript variables whose only purpose is to change the output of else Variables to lowercase or changeable undefined values ​​to backup strings (eg (not set)).


Simmer . Newsletter

Subscribe to the Simmer newsletter to get the latest news and content from Simo Ahava right in your inbox!

Tip 88: The option to format the value in GTM variables

When you create or modify any Worker In GTM, you now see a new option at the bottom of the configuration screen. Option titled Format value. By expanding it, you will see the following options:

  • Change status to… – This allows you to change the state of a variable’s output string to either one lowercase or UPPERCASE.

  • turns up null to me… This is how you can convert null values ​​for some other strings (by typing the text directly into the field), or you can get them null The output returns to another variable by selecting it from the variable selector.

  • turns up undefined to me… – As with files nullYou can get it now undefined Values ​​return to strings or the return value of other variables.

  • turns up true to me… – As above, except that you can now convert a Boolean value true to a string or the return value of some other variable.

  • turns up false to me… – As above, except that you can now convert a Boolean value false to a string or the return value of some other variable.

How is this useful? Well, take a file Issue conversion as an example. By forcing the variable output to lowercase, for example, you can flatten all of the following strings:

"I love GTM"And "i LoVe gTM"And "I LOVE GTM".

With Issue conversion set to Lowercase letters, will be the product of all three strings above "i love gtm".

Normalization is very vital in tools like Google Analytics, which treat each case of any string as unique and distinct from the others.

The ability to convert falsify values ​​like undefinedAnd null And false String representations are also useful, as you can now use something like "N/A" or "(not set)" To represent situations in which the variable does not return an appropriate value. Again, in Google Analytics, this is convenient, because GA drops undefined Fields of visits.

The Format value The option is a very useful addition to the Google Tag Manager arsenal. I just hope that the number of format options available will increase in the future, and may also allow us to write simple anonymous functions directly into the UI through which each variable output is passed.

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button