Title: Loading different group based on device
Last modified: December 15, 2017

---

# Loading different group based on device

 *  Resolved [ryann0tgosling](https://wordpress.org/support/users/ryann0tgosling/)
 * (@ryann0tgosling)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/loading-different-group-based-on-device/)
 * 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 [Text](https://wordpress.org/support/users/livechat/)
 * (@livechat)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/loading-different-group-based-on-device/#post-9796084)
 * Great question, [@ryann0tgosling](https://wordpress.org/support/users/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](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](https://wordpress.org/support/users/livechat/)
 * (@livechat)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/loading-different-group-based-on-device/#post-9796457)
 * Hello again [@ryann0tgosling](https://wordpress.org/support/users/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](https://my.livechatinc.com/agents/groups/)
   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](https://wordpress.org/support/users/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.

 * ![](https://ps.w.org/wp-live-chat-software-for-wordpress/assets/icon-256x256.
   png?rev=3023632)
 * [LiveChat - Live Chat Plugin for WP Websites](https://wordpress.org/plugins/wp-live-chat-software-for-wordpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-live-chat-software-for-wordpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-live-chat-software-for-wordpress/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-live-chat-software-for-wordpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-live-chat-software-for-wordpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-live-chat-software-for-wordpress/reviews/)

## Tags

 * [mobile](https://wordpress.org/support/topic-tag/mobile/)

 * 2 replies
 * 2 participants
 * Last reply from: [Text](https://wordpress.org/support/users/livechat/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/loading-different-group-based-on-device/#post-9796457)
 * Status: resolved