InGoogle Tag Manager, there is a built-in variable called Random number – this will return a randomised number between 0 and 2147483647 - this variable can be included to creating a session cookie with a random number.

Example Script:

<script>window.Personica('PageView',{'ExternalCookieID':{{Random Number}}})</script>

Where can I find this variable?

There are two places and both are available if you go to the Variables section in the sidebar of the Google Tag Manager interface.

The first way is to click the Configure button and then click the checkbox next to Random number.

The other one is to click the New button in the User-defined variables section, then choose the Random number option and save the variable.

There is no difference between these two options.

What does this variable do?

Simply put, the Random Number variable returns a number, randomized between 0 and 2147483647.

However, it is important to note that the number is returned every time is it invoked (read used). If two tags fire on the same dataLayer.push and they both use the same Random Number variable, both tags will use different values. It’s because the variable was used twice: by each tag separately. And each use resulted in a different random number.

Did this answer your question?