• Resolved umesh1994

    (@umesh1994)


    Hello,

    Is it Possible to create split testing only for Mobile?

    I have one way to achieve this, for testing I just cloned the same page and made changes to that variation page required for testing, But this is not adviced way because in the result. It will show the detail for both Desktop and mobile test.

    Is there any way to assign split test only for mobile devices?

    Thanks,
    Umesh.K

Viewing 1 replies (of 1 total)
  • Hi Umesh.K,

    I think you can check if a user is on mobile or not by checking the user agents. This page should give you more idea about it: https://stackoverflow.com/questions/4117555/simplest-way-to-detect-a-mobile-device.

    Using that method, you should be able to restrict the split test only on mobile devices by using this code in your functions.php file:

    function isMobile() {
        return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
    }
    
    add_action( 'wp_loaded','my_only_mobile_spt' );
    function my_only_mobile_spt() {
        if(!isMobile()){
            remove_action('template_redirect', 'sptRedirect');
        }
    }

    Please keep in mind that we can only give you an example of code. If you need something more complex, I suggest you hire a developer.

    I hope this helps ??

    Thanks,
    Okky

Viewing 1 replies (of 1 total)
  • The topic ‘Split testing only for Mobile devices’ is closed to new replies.