Created
November 17, 2011 12:40
-
-
Save googleanalyticsresoneo/1373049 to your computer and use it in GitHub Desktop.
not provided keyword upgrade for urchin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! handling of secure google search keyword being hidden and set as (not provided) for Google Analytics sites using urchin.js , not ga.js | |
* see also : http://googleblog.blogspot.com/2011/10/making-search-more-secure.html | |
* Google handles it only in ga.js, we provide it for sites using urchin.js | |
* author : analytics(at)resoneo(dot)com 2011 | |
* https://gist.github.com/1373049 | |
* usage : include urchin.js ABOVE this code, set your parameters and call urchinTracker BELOW this code */ | |
/*jslint browser: true, sloppy: true, vars: true, white: true, nomen: true, maxerr: 50, indent: 4 */ | |
/* adding some search engines */ | |
var w = _uOsr.length; | |
_uOsr[w += 1] = "myway"; | |
_uOkw[w] = "searchfor"; | |
_uOsr[w += 1] = "mysearch"; | |
_uOkw[w] = "searchfor"; | |
_uOsr[w += 1] = "need2find"; | |
_uOkw[w] = "searchfor"; | |
_uOsr[w += 1] = "babylon"; | |
_uOkw[w] = "q"; | |
_uOsr[w += 1] = "search.free"; | |
_uOkw[w] = "hidden"; | |
_uOsr[w += 1] = "search.free"; | |
_uOkw[w] = "qs"; | |
_uOsr[w += 1] = "copernic"; | |
_uOkw[w] = "hidden"; | |
_uOsr[w += 1] = "ixquick"; | |
_uOkw[w] = "hidden"; | |
_uOsr[w += 1] = "scroogle"; | |
_uOkw[w] = "hidden"; | |
_uOsr[w += 1] = "sfr.fr"; | |
_uOkw[w] = "hidden"; | |
_uOsr[w += 1] = "iminent"; | |
_uOkw[w] = "hidden"; | |
_uOsr[w += 1] = "search.m.orange.fr"; | |
_uOkw[w] = "hidden"; | |
_uOsr[w += 1] = "dogpile"; | |
_uOkw[w] = "q"; | |
_uOsr[w += 1] = "ethicle"; | |
_uOkw[w] = "q"; | |
_uOsr[w += 1] = "conduit"; | |
_uOkw[w] = "q"; | |
_uOsr[w += 1] = "delicious"; | |
_uOkw[w] = "p"; | |
_uOsr[w += 1] = "hooseek"; | |
_uOkw[w] = "recherche"; | |
_uOsr[w += 1] = "ask"; | |
_uOkw[w] = "q"; | |
_uOsr[w += 1] = "lycos"; | |
_uOkw[w] = "query"; | |
_uOsr[w += 1] = "cuil"; | |
_uOkw[w] = "q"; | |
_uOsr[w += 1] = "cluuz"; | |
_uOkw[w] = "q"; | |
_uOsr[w += 1] = "yougoo"; | |
_uOkw[w] = "q"; | |
_uOsr[w += 1] = "yauba"; | |
_uOkw[w] = "q"; | |
_uOsr[w += 1] = "voila"; | |
_uOkw[w] = "rdata"; | |
_uOsr[w += 1] = "voila"; | |
_uOkw[w] = "kw"; | |
_uOsr[w += 1] = "aol"; | |
_uOkw[w] = "q"; | |
_uOsr[w += 1] = "aol"; | |
_uOkw[w] = "query"; | |
_uOsr[w += 1] = "exalead"; | |
_uOkw[w] = "q"; | |
_uOsr[w += 1] = "alice"; | |
_uOkw[w] = "qs"; | |
_uOsr[w += 1] = "lo.st"; | |
_uOkw[w] = "x_query"; | |
_uOsr[w += 1] = "bing"; | |
_uOkw[w] = "q"; | |
/* redefining the standard urchin function to have it handle the change, and a few other improvements */ | |
function _uOrg(t) { /* manages organic traffic matching */ | |
if (_ur === "0" || _ur === "" || _ur === "-") { | |
return ""; | |
} | |
var i = 0, h, k; | |
if ((i = _ur.indexOf("://")) < 0) { | |
return ""; | |
} | |
h = _ur.substring(i + 3, _ur.length); | |
if (h.indexOf("/") > -1) { | |
h = h.substring(0, h.indexOf("/")); | |
} | |
h = h.toLowerCase(); | |
for (var ii = _uOsr.length - 1; ii >= 0; ii--) { | |
// start by the end of the list to give priority to added engines towards predefined ones | |
if (h.indexOf(_uOsr[ii].toLowerCase()) > -1) { | |
// referral within the list of known engines | |
// if parameter set to '(hidden)' for search engines hiding the keyword | |
if ((_uOkw[ii].indexOf('hidden') > -1 ) && (_ur.indexOf('?') < 0)) { | |
_ur += "?q=(not provided)"; | |
_uOkw[ii] = 'q'; | |
} | |
if ((i = _ur.indexOf("?" + _uOkw[ii] + "=")) > -1 || (i = _ur.indexOf("&" + _uOkw[ii] + "=")) > -1) { | |
k = _ur.substring(i + _uOkw[ii].length + 2, _ur.length); | |
if ((i = k.indexOf("&")) > -1) { | |
k = k.substring(0, i); | |
} | |
k = _uTrim(k); | |
// keyword parameter present but empty | |
if (( (k === "") || k.length === 0) && ( h.indexOf("google") > -1 && _ur.lastIndexOf("/") == _ur.length)) { | |
k = "(not provided)"; | |
} | |
for (var yy = 0; yy < _uOno.length; yy++) { | |
if (_uOno[yy].toLowerCase() == k.toLowerCase()) { | |
_ufno = 1; | |
break; | |
} | |
} | |
if ((k !== "") || k.length > 0) { | |
// mot clef non vide | |
if (t) { | |
return _uEC(k); | |
} | |
else { | |
return "utmccn=(organic)|utmcsr=" + _uEC(_uOsr[ii]) + "|" + "utmctr=" + _uEC(k) + "|utmcmd=organic"; | |
} | |
} | |
// empty keyword : next engine | |
} | |
// parameter not found in referral : next engine | |
} | |
} | |
return ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment