Support » Plugin: LiveChat - WP live chat plugin for WordPress » Loading different group based on device

  • Resolved ryann0tgosling


    Hello guys!

    I have integrated your LiveChat plugin with my WordPress and I was wondering if there is any way to specify which group created by me should load for which device.

    To provide a better explanation, let me give you an example:
    Let’s say that a customer is visiting my page from his iPhone. Is it possible for LiveChat to load a specific group for that customer, as opposed to a customer visiting my website from desktop computer?

    I will truly appreciate any tip/advice from you guys!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author LiveChat


    Great question, @ryann0tgosling!

    If you have a mobile version of your website with a sub-domain as such, you can load a specific group for mobile users using the URL rules functionality (/user visits a page address/ + /that contains/ +

    Hope this helps.

    Plugin Author 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:

    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;
       = <?php echo $group; ?>;
                (function () {
                    var lc = document.createElement('script');
                    lc.type = 'text/javascript';
                    lc.async = true;
                    lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + '';
                    var s = document.getElementsByTagName('script')[0];
                    s.parentNode.insertBefore(lc, s);

    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 2 years, 9 months ago by LiveChat. Reason: Added code formatting
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Loading different group based on device’ is closed to new replies.