Plugin Author
Text
(@livechat)
Great question, @ryann0tgosling!
If you have a mobile version of your website with a sub-domain as such m.yourwebsite.com, you can load a specific group for mobile users using the URL rules functionality https://www.livechatinc.com/kb/setting-up-url-rules-for-groups/#changing-customization (/user visits a page address/ + /that contains/ + m.yourwebsite.com).
Hope this helps.
Plugin Author
Text
(@livechat)
Hello again @ryann0tgosling! We have got one additional solution for you. If you’d like to truly load specific groups based on a mobile device (group A for iPhone users for example), we have prepared a PHP script that will do just that. It will require adding LiveChat code to your WordPress manually (instead of a plugin) but it will do the work. You can check the example representing both, the script and the LiveChat code below:
<?php
function getUserAgent()
{
$agent = null;
$agent = $_SERVER['HTTP_USER_AGENT'];
if ( stripos($agent, 'iPhone') !== false ) {
$agent = 'iphone';
} elseif ( stripos($agent, 'iPad') !== false ) {
$agent = 'ipad';
} elseif ( stripos($agent, 'Android') !== false ) {
$agent = 'android';
} elseif ( stripos($agent, 'Chrome') !== false ) {
$agent = 'chrome';
} elseif ( stripos($agent, 'Safari') !== false ) {
$agent = 'safari';
} elseif ( stripos($agent, 'Firefox') !== false ) {
$agent = 'firefox';
}
return $agent;
}
$agent = getUserAgent();
$group = 0;
if($agent === 'iphone' || $agent === 'ipad' || $agent === 'android')
{
$group = X;
}
else if($agent === 'chrome' || $agent === 'safari' || $agent === 'firefox')
{
$group = X;
}
?>
<script type="text/javascript">
var __lc = {};
__lc.license = 7536651;
__lc.group = <?php echo $group; ?>;
(function () {
var lc = document.createElement('script');
lc.type = 'text/javascript';
lc.async = true;
lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.livechatinc.com/tracking.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(lc, s);
})();
</script>
This script detects the mobile user agent and, based on that, can load a different group. In the example above the script will load different group for iOS and Android visitors and different groups for desktop visitors.
NOTE that the group is represented by X – remember to replace X with the numeric representation of your group ID. How to find it? The easiest way is to go to your LiveChat Groups section (or click here to get right there) > choose a group > the ID of this group will be displayed at the end of the URL.
I hope that we were able to help! In case of any additional issues, please don’t hesitate to ask.
-
This reply was modified 8 years, 6 months ago by
Text. Reason: Added code formatting