I assume, that you implement mobile application and website yourself and need to detect your own application vs. browser. I've been practicing a different solution for this.
When application runs in the mobile, you can insert a javascript bridge object into the browser's context. When application runs in browser, you check if the javascript bridge object is present and, if not, you emulate it.
All you need it to have a method for both cases something like:
nativeBridge.getClientId();
where for web you will implement it like:
if( !window.nativeBridge ){
window.nativeBridge = {
getClientId:function(){ return "web"; }
}
}
for web view you will have to add a method to the bridge that returns a different constant.
NOTE: 'nativeBridge' is just a name. you may have a different object name.