How can I only fire a tag from Monday to Friday 09.00-17.00?

Solution 1:

Preferred solution

The best solution is probably to get the current date on the server side and push to the datalayer a variable that determines whether the chat tag should be triggered or not depending on this date.

Alternative

The alternative is to retrieve the date on the client side which won't be 100% reliable. In order to use this solution, you need to create a Custom Javascript variable with the following code (replace "America/New_York" by your business' timezone) :

function (){
    const currentDate = new Date(new Date().toLocaleString("en-US", {timeZone: "America/New_York"}));
    const day = currentDate.getDay()
    const hours = currentDate.getHours()
    return day > 0 && day < 6 && hours >= 9 && hours < 17
}

Then, trigger your chat tag only when this variable's value is "true".