- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
03-04-2015 10:03 PM - last edited on 05-19-2016 02:53 PM by kathleen_jo
You can now create load rules to include date- and time-specific conditions to load a Tag.
You can determine when a tag loads by specifying a time or date range.
1. Click the Add Date Range Condition Button. The new Date Range condition will appear.
2. Specify a start date by clicking in the first Start field. A calendar will appear, allowing you to select the desired start date.
3. To specify a start time, click in the second Start field. A table will appear, allowing you to select a start time. The smallest increment of time you can select is a five-minute period.
4. To specify an end date, click in the first End field. A calendar will appear allowing you to select the end date.
5. To specify an end time, click in the second End field. A table will appear allowing you to select the end time.
6. Create a normal condition that will evaluate as true. If you do not have a normal condition as part of your time-based load rule, it will always evaluate as false.
7. Click Apply to create the load rule. You can now use this load rule to control when a Tag loads.
If you do not want to use the web browser's local time, you can also use UTC time by doing the following.
Use the following CSV for Bulk Import Data Sources into TiQ
datetime_year_utc, "UDO Variable", "Will output a number. ex: 2015" datetime_month_utc, "UDO Variable", "Will output a number. ex: 5" datetime_day_utc, "UDO Variable", "Will output a number. ex: 7" datetime_day_string_utc, "UDO Variable", "Will output a string. ex: Fri" datetime_hour_utc, "UDO Variable", "Will output a number in military time. ex: 23" datetime_minute_utc, "UDO Variable", "Will output a number. ex: 57" datetime_second_utc, "UDO Variable", "Will output a number. ex: 7" datetime_epoch_utc, "UDO Variable", "Will output a Unix timestamp. ex: 1431057424923" datetime_string_utc , "UDO Variable", "Will output a string. ex: 2015-05-08 03:57:04 UTC"
Then copy and paste the following code into a JavaScript Extension scoped to Pre Loader.
(function(d,y,m,da,dn,h,mi,s,ep,padL,days){ padL=function(str,len,char){ return (new Array((len||1)+1).join(char||0)+(str||'')).slice(-(len||2)) } window.utag_data=window.utag_data||{} days="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"); d=new Date(); y=d.getUTCFullYear(); m=d.getUTCMonth()+1; da=d.getUTCDate(); dn=days[d.getUTCDay()]; h=d.getUTCHours(); mi=d.getUTCMinutes(); s=d.getUTCSeconds(); ep=d.getTime(); utag_data.datetime_year_utc=y; utag_data.datetime_month_utc=m; utag_data.datetime_day_utc=da; utag_data.datetime_day_string_utc=dn; utag_data.datetime_hour_utc=h; utag_data.datetime_minute_utc=mi; utag_data.datetime_second_utc=s; utag_data.datetime_epoch_utc=ep; utag_data.datetime_string_utc=y+"-"+padL(m)+"-"+padL(da)+" "+padL(h)+":"+padL(mi)+":"+padL(s)+" UTC"; })();
Now you can use the new variables in load rules. Just make sure you use a site like:
http://www.worldtimeserver.com/current_time_in_UTC.aspx
or
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=local+time+to+utc
to convert the timezone you are on to UTC so you know what values to put into the Load Rule.
This has some interesting use cases like: Only show the chat popup on weekdays between 8AM and 5PM Eastern Time. Obviously the time would need to be converted first and there are edge cases around day light savings time. However it gets us much closer to solving for this.
A second use case this supports is something like: Only show this popup message during the Superbowl.
Is there a way to create a load rule that fires a pixel after a specific length of time? For example, fire pixel 2 minutes after the page has loaded.
that is pretty easy to do with a Tealium JavaScript Extension scoped to DOM Ready.
In the code below, just replace the JSON_OBJECT with the object you want to send. For your example, utag_data might work just as well as anything else. And then replace TAG_ID with the apporiate UID from the Tags Tab in Tealium iQ
setTimeout(function(){utag.view(JSON_OBJECT, null, [TAG_ID])}, 120000)
You can read more about utag.view here:
https://community.tealiumiq.com/t5/Developers/utag-link-and-utag-view/m-p/75/highlight/true#M309
You can read more about setTimeout here:
http://www.w3schools.com/jsref/met_win_settimeout.asp
Brian
@tester1234 DOM Ready, I updated the post to reflect this information.
Copyright All Rights Reserved © 2008-2023