- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
09-08-2021 03:04 PM
10-04-2021 03:56 PM
Hi Arya!
Typically if I was building something like this, I'd probably use a JS extension - but I like a good challenge, so I've found a way to do it that doesn't use any JS. This solution uses the User Agent string, which has its own problems (not least of which: Google is working to phase them out in Chrome), but in any case:
Step 1: Data Layer Variables
UDO Variable: is_safari, to hold the true/false state:
JS Variable: navigator.userAgent, to read the User Agent string from the browser:
Step 2: Extensions
Set Data Values extension scoped to Before Load Rules, set is_safari to false - this provides a default state:
Another Set Data Values extension, also scoped to Before Load Rules (but run after the previous extension), set is_safari to true when the User Agent string contains the word Safari. There are a bunch of conditions here, owing to the way various non-Safari browsers set things up:
In case those conditions are hard to read, here they are in order:
There may be other non-Safari User Agents out there that contain Safari and also something else, but the above should catch most of them (it seems most non-Safari browsers use the Safari + Chrome combination).
Hope this is helpful!
- zac.
Copyright All Rights Reserved © 2008-2023