Hi!
Any insights or recommendations on how to track if a visitor uses incognito browsing when visiting a website?
There are several ways to identify if the visitor ID was previously unseen (i.e. Visit Number = 1), but this does not infer the user using incognito browsing mode.
Ideally, an s.prop-value or an Omniture/Adobe Analytics plugin would be able to detect the browser mode, so a distinction between 'standard' and 'incognito'/'in-private' can be made.
Any help would be much appreciated :)
Martin
Solved! Go to Solution.
Actually, I've found a workaround that works for most major browsers except IE. I've been running some tests and not seen any misdetection.
The javascript I'm using is this - but it might have some holes I'm missing? If you're aware of this, please let me know :)
Script:
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
// Internet Explorer 6-11
var isIE = /*@cc_on!@*/false || !!document.documentMode;
// Edge 20+
var isEdge = !isIE && !!window.StyleMedia;
// Chrome 1+
var isChrome = !!window.chrome && !!window.chrome.webstore;
// Blink engine detection
var isBlink = (isChrome || isOpera) && !!window.CSS;
if (!isEdge && !isIE) {
new Promise(function (resolve) {
var db,
on = function(){ resolve(true) },
off = function(){ resolve(false) },
tryls = function tryls() {
try {
localStorage.length ? off() : (localStorage.x = 1, localStorage.removeItem("x"), off());
} catch (e) {
// Safari only enables cookie in private mode
// if cookie is disabled then all client side storage is disabled
// if all client side storage is disabled, then there is no point
// in using private mode
navigator.cookieEnabled ? on() : off();
}
}
// Blink (chrome & opera)
window.webkitRequestFileSystem ? webkitRequestFileSystem(0, 0, off, on)
// FF
: "MozAppearance" in document.documentElement.style ? (db = indexedDB.open("test"), db.onerror = on, db.onsuccess = off)
// Safari
: /constructor/i.test(window.HTMLElement) ? tryls()
// IE10+ & edge
: !window.indexedDB && (window.PointerEvent || window.MSPointerEvent) ? on()
// Rest
: off();
}).then(function (isPrivateMode) {
if (isPrivateMode) {
b.privateBrowsing = "Yes"
}
});
}
Hi Martin,
Unfortunately, this is not possible due to the way that browsers completely clear all cache, cookies, and history when accessing Incognito/Privacy Mode. Other than those three items being cleared, there's no other way to identify that a user is running their browser in these modes. Here's some more information on why this is not possible: http://stackoverflow.com/a/22623958
Views
Replies
Total Likes
Actually, I've found a workaround that works for most major browsers except IE. I've been running some tests and not seen any misdetection.
The javascript I'm using is this - but it might have some holes I'm missing? If you're aware of this, please let me know :)
Script:
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
// Internet Explorer 6-11
var isIE = /*@cc_on!@*/false || !!document.documentMode;
// Edge 20+
var isEdge = !isIE && !!window.StyleMedia;
// Chrome 1+
var isChrome = !!window.chrome && !!window.chrome.webstore;
// Blink engine detection
var isBlink = (isChrome || isOpera) && !!window.CSS;
if (!isEdge && !isIE) {
new Promise(function (resolve) {
var db,
on = function(){ resolve(true) },
off = function(){ resolve(false) },
tryls = function tryls() {
try {
localStorage.length ? off() : (localStorage.x = 1, localStorage.removeItem("x"), off());
} catch (e) {
// Safari only enables cookie in private mode
// if cookie is disabled then all client side storage is disabled
// if all client side storage is disabled, then there is no point
// in using private mode
navigator.cookieEnabled ? on() : off();
}
}
// Blink (chrome & opera)
window.webkitRequestFileSystem ? webkitRequestFileSystem(0, 0, off, on)
// FF
: "MozAppearance" in document.documentElement.style ? (db = indexedDB.open("test"), db.onerror = on, db.onsuccess = off)
// Safari
: /constructor/i.test(window.HTMLElement) ? tryls()
// IE10+ & edge
: !window.indexedDB && (window.PointerEvent || window.MSPointerEvent) ? on()
// Rest
: off();
}).then(function (isPrivateMode) {
if (isPrivateMode) {
b.privateBrowsing = "Yes"
}
});
}
Views
Likes
Replies
Views
Like
Replies