Thanks for reaching out to Adobe community
You could create a profile script with following code :
var d = new Date(); return d.getHours();
Then create an audience in a way shown in the attachment (ReturnDayOfWeek is the name of profile script). Please make sure to take into account timezone of your customers with server's timezone.
Audience.png 51.1 K
Thank you very much! It works just as expected. Do you know if there is a way to have the script check the time upon every page load? The ideal outcome would be that when the specified time window is not met, it shows the default experience for all audiences. When the clock turns and the time aligns with the service hours, the experience generates.
We are finding that the browser cache holds onto the experience timestamp so we must clear the history each to push through the change.
I just confirmed at my end, for an experience targeting activity profile script values update on every load. And therefore your experience should update when time aligns with service hours.
Could you please share the URL / activity where you see the experience sticking so I can debug?
Yes, Thank you.
The experience is specific to MOBILE. Between 7- 9pm the user has the ability to direct call for the service. Anything later than 9 pm or earlier in the morning before 7 am, that ability is removed and only an option to learn about the service is shown.
If time is between 7am-9pm: https://www.marshfieldclinic.org/?at_preview=ngFY2q60BNC3Zzs1D086240uQILwur
If time is between 9pm - 7am: https://www.marshfieldclinic.org/?at_preview=OXNj0ptBB7GEIG55wqZAMke2Xx52fe
The test is live at: https://www.marshfieldclinic.org/?qa=true Be sure to size browser to less than 480px to see changes
Snapshots of the audience profiles are attached.
I would recommend you to use 'is greater than or equal to' and 'is less than or equal to' in your 7AM-9PM segment.
With the current implementation of segments, when hour of day is 7 or 21, user will see default offer. And, this may be the case when you checked. I have debugged and found that the script is sending the updated value and it should not be a concern.
- 7-9 daytime segment is effective from 8AM-8PM (due to absence of equal to operator)
- 9-7 evening segment is effective from 10PM-6AM
- 0700-0759 hours and 2100-2159 hours will show default content (not even entering your campaign).
Please make the changes.
Thank you! You have helped our business take a big leap forward.