We run Live Chat as a domain-wide global JavaScript across all our landing pages.
Now, we get traffic from a few different lead providers running email campaigns and co-registration campaigns for us.
As most of these are pay per lead, they don’t like us having Live Chat on our landing pages for them. Whereas we definitely want LC on all our PPC campaign pages; AdWords, Bing, Facebook Ads, etc.
So, I was faced with having to disable the global chat JS and place it into 90% of our pages, leaving it off only the pay per lead provider pages, or working out a method to exclude those specific pages from loading the Live Chat script.
Here’s the simple test code I came up with.
Can anyone suggest improvements or point to any potential problems?
So let’s say you need to exclude provider1 and provider2 and you have their landing pages all containing string1 and string2 in the URLs. That’s what we do.
The code wrapper looks like this…