Hello,
Could you tell me how using the JS API, I can display the widget only if the URL contains the word CHARTER or destinations?
Many thanks in advance.
Hello,
Could you tell me how using the JS API, I can display the widget only if the URL contains the word CHARTER or destinations?
Many thanks in advance.
Hi Steven!
Are you confident you’d like to achieve that result using JS API specifically?
This could be very easily achieved with LiveChat without using any kind of API - if you’re interested, do let me know
In terms of achieving this with JS API
var location === window.location.href
if(location.includes('charter' || 'destinations')) >= 0){
our chat script here
}
which simply translates to,
if URL visitor is on contains a string ‘charter’ or ‘destinations’ load the LiveChat script
Alternatively instead of loading or not loading our script entirely based on the url - you could load it everywhere and set default position of the widget to ‘Always hide minimized widget icon’ here
and then load our script everywhere by default but show it based on url like this:
var location === window.location.href
if(location.includes('charter' || 'destinations')) >= 0){
LiveChatWidget.call("maximize");
}
I hope that helps!