Skip to content

Instantly share code, notes, and snippets.

@koconder
Created June 23, 2014 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koconder/6a25bb8933eff572abbc to your computer and use it in GitHub Desktop.
Save koconder/6a25bb8933eff572abbc to your computer and use it in GitHub Desktop.
ga.js Google Analytics - Organic Sources snippet
//Taken from http://www.google-analytics.com/ga.js
//And de-compressed
var Ld = "daum:q eniro:search_word naver:query pchome:q images.google:q google:q yahoo:p yahoo:q msn:q bing:q aol:query aol:q lycos:q lycos:query ask:q cnn:query virgilio:qs baidu:wd baidu:word alice:qs yandex:text najdi:q seznam:q rakuten:qt biglobe:q goo.ne:MT search.smt.docomo:MT onet:qt onet:q kvasir:q terra:query rambler:query conduit:q babylon:q search-results:q avg:q comcast:q incredimail:q startsiden:q go.mail.ru:q centrum.cz:q 360.cn:q sogou:query tut.by:query globo:q ukr:q so.com:q auone:q".split(" "),
Sd = function (a) {
if (a.get(kb) && !a.get(Mc)) {
var b;
b = !F(a.get(ic)) || !F(a.get(nc)) || !F(a.get(S)) || !F(a.get(lc));
for (var c = {}, d = 0; d < Md[w]; d++) {
var e = Md[d];
c[e] = a.get(e)
}(d = a.get(rc)) ? (H(149), e = new Ja, Na(e, d), d = e) : d = La(J[z][xa], a.get(gb)).d;
if ("1" != L(d.get(a.get(ub))) || !b)
if (d = Xe(a, d) || Qd(a), d || b || !a.get(ac) || (Pd(a, void 0, "(direct)", void 0, void 0, void 0, "(direct)", "(none)", void 0, void 0), d = !0), d && (a.set(hc, Rd(a, c)), b = "(direct)" == a.get(nc) && "(direct)" == a.get(jc) && "(none)" == a.get(oc), a.get(hc) || a.get(ac) &&
!b)) a.set(ec, a.get(ab)), a.set(fc, a.get($b)), a.Za(gc)
}
},
Xe = function (a, b) {
function c(c, d) {
d = d || "-";
var e = L(b.get(a.get(c)));
return e && "-" != e ? I(e) : d
}
var d = L(b.get(a.get(nb))) || "-",
e = L(b.get(a.get(qb))) || "-",
f = L(b.get(a.get(pb))) || "-",
Be = L(b.get("gclsrc")) || "-",
k = L(b.get("dclid")) || "-",
s = c(ob, "(not set)"),
t = c(rb, "(not set)"),
Za = c(sb),
Ma = c(tb);
if (F(d) && F(f) && F(k) && F(e)) return !1;
var mb = !F(f) && !F(Be),
mb = F(e) && (!F(k) || mb),
Xb = F(Za);
if (mb || Xb) {
var Bd = Nd(a),
Bd = La(Bd, !0);
(Bd = Od(a, Bd)) && !F(Bd[1] && !Bd[2]) && (mb &&
(e = Bd[0]), Xb && (Za = Bd[1]))
}
Pd(a, d, e, f, Be, k, s, t, Za, Ma);
return !0
},
Qd = function (a) {
var b = Nd(a),
c = La(b, !0);
(b = !(void 0 != b && null != b && "" != b && "0" != b && "-" != b && 0 <= b[q]("://"))) || (b = c && -1 < c[u][q]("google") && c.d.contains("q") && "cse" == c[ra]);
if (b) return !1;
if ((b = Od(a, c)) && !b[2]) return Pd(a, void 0, b[0], void 0, void 0, void 0, "(organic)", "organic", b[1], void 0), !0;
if (b || !a.get(ac)) return !1;
t: {
for (var b = a.get(Bb), d = Ka(c[u]), e = 0; e < b[w]; ++e)
if (-1 < d[q](b[e])) {
a = !1;
break t
}
Pd(a, void 0, d, void 0, void 0, void 0, "(referral)",
"referral", void 0, "/" + c[ra]);
a = !0
}
return a
},
Od = function (a, b) {
for (var c = a.get(zb), d = 0; d < c[w]; ++d) {
var e = c[d][y](":");
if (-1 < b[u][q](e[0][D]())) {
var f = b.d.get(e[1]);
if (f && (f = K(f), !f && -1 < b[u][q]("google.") && (f = "(not provided)"), !e[3] || -1 < b.url[q](e[3]))) {
f || H(151);
t: {
for (var c = f, d = a.get(Ab), c = I(c)[D](), Be = 0; Be < d[w]; ++Be)
if (c == d[Be]) {
c = !0;
break t
}
c = !1
}
return [e[2] || e[0], f, c]
}
}
}
return null
},
Pd = function (a, b, c, d, e, f, Be, k, s, t) {
a.set(ic, b);
a.set(nc, c);
a.set(S, d);
a.set(kc, e);
a.set(lc, f);
a.set(jc, Be);
a.set(oc,
k);
a.set(pc, s);
a.set(qc, t)
},
Md = [jc, ic, S, lc, nc, oc, pc, qc],
Rd = function (a, b) {
function c(a) {
a = ("" + a)[y]("+")[C]("%20");
return a = a[y](" ")[C]("%20")
}
function d(c) {
var d = "" + (a.get(c) || "");
c = "" + (b[c] || "");
return 0 < d[w] && d == c
}
if (d(S) || d(lc)) return H(131), !1;
for (var e = 0; e < Md[w]; e++) {
var f = Md[e],
Be = b[f] || "-",
f = a.get(f) || "-";
if (c(Be) != c(f)) return !0
}
return !1
},
Td = new RegExp(/^https?:\/\/(www\.)?google(\.com?)?(\.[a-z]{2}t?)?\/?$/i),
jf = /^https?:\/\/r\.search\.yahoo\.com\/[^?]*$/i,
Nd = function (a) {
a = Pa(a.get(Jb), a.get(P));
try {
if (Td[ia](a)) return H(136), a + "?q=";
if (jf[ia](a)) return H(150), a + "?p=(not provided)"
} catch (b) {
H(145)
}
return a
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment