Days In Seconds variable for Google Tag Manager (GTM) offers an easy yet effective solution for converting a specified number of days into seconds. This is especially valuable in situations where time-based calculations are required, as GTM commonly uses seconds as the standard unit for many server-side configurations.
The initial development of this template was done by Lars Friis, and it is now maintained by Stape.
The variable takes an input representing a number of days and multiplies it by the number of seconds in a day (86,400 seconds) to provide the equivalent value in seconds. By using this variable, you can easily handle configurations that require precise time intervals for things like session expirations, cache durations, or setting cookie lifetimes, which are often specified in seconds in GTM server-side setups.
This automation reduces the chance of manual errors and ensures that time-based configurations are accurate. You can also use this approach for handling session expirations, cache controls, or any server-side function that depends on a time interval in seconds.
2. Download Days In Seconds variable on GitHub or add it from the Template Gallery. Import the variable to server Google Tag Manager container by clicking Templates → New Variable Template. Click three dots in the top right corner → Click import → Add template that you’ve recently downloaded → Click Save.
3. Set the number of days that will be turned into seconds. Click Save.
Beyond its simplicity, the Days In Seconds variable is versatile. It can be applied in various scenarios, such as defining cookie expiration times, controlling session durations, or managing cache settings. Whether you're configuring server-side events or optimizing user tracking, this variable ensures that time intervals are accurately reflected in seconds, reducing potential misconfigurations and simplifying ongoing maintenance.
We are happy to hear that! Click on Try for free to register and check all the possibilities.