GTM Community Template - Value Range Variable

GTM Community Template - Value Range Variable

The Value Range variable is the custom variable template created for the Google Tag Manager community template galery.

Provided numeric input is translated into a range with the step size declared in the settings of the variable (e.g.130 => 101-150, where step size is 50).

This could be used as a dimension/parameter/property in tags like Google Analytics. The perfect example would be an e-commerce event where a monetary value could be transformed into a cluster-dimension or a user property, rather than a metrical value, which gives an extra breadth in the analytics report. Certainly, there are many more use cases outside of e-commerce.

alt text

Required input

The input must match a pattern of the positive numeric value. The floating point numbers will be rounded down before converting it to the range. The negative value will result in <1 by default.

The step size implies the window; the lower is the provided step size, the higher cardinality could be expected in the reports, supposedly, on a dimension level. For example, if the input value is 50 and the step size is set to 25, the output will be 26-50. It is difficult to think of the case where the counterintuitive settings should be applied, although, if the step size is <=1, an input value will be returned back.

Optional settings

To provide a control over the cardinality, or if you are just interested in analyzing ranges until certain point, the upper bound as well as the lower bound threasholds can be set. What happens, for example, if the range upper bound is set to 2000, and the input value is 2500, the output will be 2000+. Similarly for the lower bound, if the range lower bound is set to 20, and the input value is 15, the output will be <20.

If both, the upper bound and the lower bound are enabled, then the upper bound is expected to be greater and has a higher priority in capping the range. If both are equal to to the input value, then the input value will be returned.

Combination of these settings and thus, the functionality of the variable may be abused by the user input, especially if it arrives from the unprdictable referenced variables. Quite some time was put into optimizing this template and testing against the most dummy cases you could potentially think, however, it is still good to address the topic of edge cases.

Resources

GitHub
Cummunity Template Gallery