The Custom Variable Template to get the amount of full days, hours, etc. between the first and the second date or Date.now().
The variable template can help you to build triggers in which you need to compare a date of a previous event with the current date. The date of previous event should be in Unix Time, result of Date.now().
- Go to Templates Page;
Search Galleryin Variable Templates section;
Days, Hours or Minutes Between Two Dates. In the list of templates click on the template;
Add to workspacebutton;
- Go to Variables page;
Addbutton, select the template from the list;
- Set variable name;
- Set value for
First Datefield. Usually it’s GTM variable contains Unix Time. For example it can be a 1st Party Cookie GTM Variable with the name
cookie.previous_event_time. Put the name of the variable like this
- If you need to compare with the current time set the
Now. If you need to compare with a second date, select
Other dateand put the date or GTM Variable with the date in
- Set the
Time Unit, by default it sets to
Days. But if you need to compare dates in hours, minutes or seconds – please change
- Now you can use the new variable in triggers and compare the value using
less thanoperators with a needed amount of days (or other time units based on your setup).
- Create trigger on login event but X days after registrations
- Create trigger on purchase event in the same day as previous purchase
- Create trigger on purchase event but not less than X days after visiting blog