GTM Template – Variable – Time Converter

Simply use this variable to calculate a conversion between Time Units. No more need to use converters or do the calculation yourself, this variable does it for you! Seconds to Milliseconds; Milliseconds to Days;…

Load The Custom Variable Time Converter from the Community Template Gallery

Important message: Important message: I’m not a developer, I’m using GTM Custom Template for my own personal enjoyment, learning Javascript and help GTM users to let their experiences easier!

First, go find & load the custom variable to your GTM container.

Add the Cookie Creator Variable to your account

Configure Time Converter Variable

Once you have uploaded the variable in your container, the configuration is very easy to do!

  • Fill with a numerical value (you can fill yourself or use a GTM variable that returns a unit value)
  • Selecting the starting time value unit
  • Selecting the arrival time value unit
Screenshot of Time Converter Custom Variable in Google Tag Manager

Test the variable and check the value

Screenshot of GTM Preview

Uses cases

Using the variable for setup Cookie Expire Field To Set in Google Analytics Settings. Example: by default, the Google Analytics cookie is set up for 24 months but with the GDPR & CNIL law in France, we must set up the GA Cookie at 13 months. This variable can help you to convert 13 months in seconds, the time unit expected by this field.

You can also use the Time Converter to setup the lifetime of a custom cookie

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *