Back to Code List
javascript

Channel Manager (External Traffic) Plugin

This is the SiteCatalyst Channel Manager plugins. It can also be known as the external traffic plugin. This has been adapted to work for any analytics that you'd like. This tracks various types of referring traffic based on natural or paid searches among other things. More information can be found in the tooltips.

This plugin is possibly one of the hardest to understand and implement correctly, but it can be extremely useful. The newer SiteCatalyst versions have this built in and can be used for processing rules. However, this is still useful if needed outside of Adobe or if you need to have custom tweaking.

While not exactly the same setup, I've found that this site helps with the basic setup for the different string values: http://maassmedia.com/blog/omniture-channel-manager-plugin/

   tooltips.txt

tooltips

Description:
    Tracks referring urls and classifies them for external traffic sources.

REQUIRED:    
Query Param:
    A list of parameters to watch for on the url. Values can be comma separated with no space to track them. Examples: "cmp", "cmp,cid".
Channel Domain:
    See additional extension info. Example: Social Networks|facebook.com,twitter.com,digg.com>News Sites|cnn.com,msn.com,nytimes.com
Channel Parameter:
    See additional extension info. Example: External Campaign|CMP
Channel Pattern:
    See additional extension info. Example: Email Campaign|EMC>Banner Ad Campaign|BAC>Paid Search Campaign|KNC>CMC|CMC
    
OPTIONAL:
Delimiter:
    Delimiter used to separate query string parameter values if multiple values are found. If omitted and multiple parameters from p are found, the strings are appended to each other without a delimiter.
Internal Link Filters:
    A comma separated list of domains to include as internal links. If using SiteCatalyst, this is identical to the input there. Example: mysite.com,stuartrosk.com,sample.stuartrosk.com
Extra Search Engines:
    See additional extension info. Example: bing.com|q|Microsoft bing
Referral URL Override:
    A data source to manually input the referring url on a page. Defaults to document.referrer (js).
Direct Load:
    A switch on whether to use Direct Load or not. See additional extension info.
Once Per Session:
    A switch on whether to report the channel once per session or whether to report it on every page.
    
Additional Extension Info:
    This extension is used to track external traffic sources. There are several types of tracking involved with this extension namely:
        Paid Non-Search
        Paid Search
        Natural Search
        Direct Load
        Referrers
    The five types are determined with the following rules:
        Direct Load will only appear if the following conditions are met:
            1) On the first page of the visit
            2) The inputted query param is not defined or has no value
            3) The switch for direct load is "yes"
            4) There is NOT a document.referrer (e.g. page was typed into URL bar)
        If any of these are false, the following other scenarios can happen:
            1) If a) on the same domain as previous page and b) the query param has a value, then type will result in "Paid Non-Search"
            2) If a) on the same domain and b) the query param doesn't have a value, then type will result in "Referrers"
            3) If coming from a search engine in the search engine list (below) or from an added search engine:
                a) _et_partner will be set appropriately to search engine name
                2) _et_keywords will contain keywords from referrer url
                3) If query param has a value, will result in "Paid Search" else will result in "Natural Search"
        There is the chance that all values can get set to "". This happens in two instances:
            1) When the document.referrer is in the list of internal link filters.
            2) If on the first page of a visit where the following is true:
                a) query param isn't defined
                b) direct load is set to "no"
                c) no referral url is defined
    In order for this extension to function properly, three additional items must be defined. They are as such:
        Channel Domain: a list of name|value pairs (separated by a greater than (">")) for all of your channels that are identified solely based on the referring website.  For channels that are comprised of multiple websites, separate the values with a comma (",").
        Channel Parameter: accepts one name|value pair only.  The name is the default channel for all visitors that enter the site with the value as a query string parameter.  If a visitor comes to mysite.com/?CMP=test and the value for this was "External Campaign|CMP", they would fall into the "External Campaign" channel.
        Channel Pattern: accepts the same sort of list as Channel Domain.  The difference is that channels in this variable are determined based on their campaign code.  If a visitor came to mysite.com/?CMP=KNC-test and the pattern was "Email Campaign|EMC>Banner Ad Campaign|BAC>Paid Search Campaign|KNC", they would fall into the "Paid Search Campaign" channel.
    Other descriptions are mentioned if you hover on the fields for this extension. A further description is required for Extra Search Engines. This field appends custom search engines onto a list that is predefined in the extension (below). If you'd like to add multiple search engines, you would put it into the following format:
        bing.com|q|Microsoft Bing
    where the first item is the domain, the second is the query param for the keywords in their url if you were to search on their site, and the third being the name of the site. If you would like to add multiple, just separate them with a ">" similar to the channel fields.
    
    Pre-defined Search Engines with their keyword query params:
    
    search.about.com|terms|About.com>alltheweb.com|query,q|All The Web>altavista.co,altavista.de|q,r|AltaVista>.aol.,suche.aolsvc.de|q,query|AOL>ask.jp,ask.co|q,ask|Ask>www.baidu.com|wd|Baidu>business.com/search|query|Business.com>clix.pt|question|Clix>cuil.com|q|Cuil>daum.net,search.daum.net|q|Daum>eniro.|search_word|Eniro>goo.ne.jp,search.mobile.goo.ne.jp|MT|Goo (Jp.)>google.,googlesyndication.com|q,as_q|Google>icqit.com|q|icq>ixquick.com|query|ixquick>bing.com|q|Microsoft Bing>lycos.|query|Lycos>mail.ru/search,go.mail.ru/search|q|Mail.ru>bing.com|q|Microsoft Bing>myway.com|searchfor|MyWay.com>netscape.com|query,search|Netscape Search>reference.com|q|Reference.com>searchalot.com|query,q|Searchalot>seznam|w|Seznam.cz>busca.uol.com.br|q|UOL Busca>usseek.com|string|Usseek>virgilio.it|qs|Virgilio>web.de|su|Web.de>yahoo.com,yahoo.co.jp|p,va|Yahoo!>yandex|text|Yandex.ru>search.cnn.com|query|CNN Web Search>search.earthlink.net|q|Earthlink Search>search.comcast.net|q|Comcast Search>search.rr.com|qs|RoadRunner Search>optimum.net|q|Optimum Search    

   code_to_paste.js

// change these as needed
    // required
        var query_param = "query param name"; //e.g. CMP
        var channel_domain = "";        //ex.: Social Media|facebook.com,twitter.com,digg.com,linkedin.com,myspace.com
        var channel_parameter = "";   //ex.: External Campaign|CMP
        var channel_pattern = "";        //ex.: Email|EM>Social Media|SM>Paid Search|PPC>Affiliates|AFL>Display Ads|DSP>Shopping Comparison|SCC>Content|CON>Text Messages|TXT
    // optional
        var delimiter = "";
        var link_filters = "";
        var extra_search_engines = "";
        var referral_url_or = "";
        var direct_load = 1;
        var once_per_session = 1;

// end changes

//output will appear in this variable
//use data as needed. The most commonly used is
//the "channel" variable
var b = {};
 
(function (f,l,n,W,DD,K,J,R,e,d,Z,c,g,h,i,j,k,m,o,p,q,r,s,t,u,A,B,C,D,E,F,G,H,I,L,M,N,O,P,Q,S,U,X) {
    r = function (w, x, y, z) {
            // read cookie
            x = w + "=";
            y = document.cookie.split(';');
            for (var i = 0; i < y.length; i++) {
                z = y[i];
                while (z.charAt(0) == ' ')
                    z = z.substring(1, z.length);
                if (z.indexOf(x) == 0)
                    return z.substring(x.length, z.length);
            }
            return "";
        };
    q = function (x, y, z) {
            // set cookie
            if (typeof z == "number") z = new Date(z);
            document.cookie = x + "=" + y + ";path=/;domain=" + location.hostname + ";expires=" + (z?z.toGMTString():"");
        };
    s = function(v,w,x,y,z) {
            x = 0,
            z = new Array;
            while (v) {
                y = v.indexOf(w);
                y = y > -1 ? y : v.length;
                z[x++] = v.substring(0, y);
                v = v.substring(y + w.length);
            }
            return z
        };
    B = function (x, y, z) {
            var i = x.indexOf(y);
            while (x && i >= 0) {
                x = x.substring(0, i) + z + x.substring(i + y.length);
                i = x.indexOf(y, i + z.length)
            }
            return x
        };
    F = function (p, d, u, U,V,W,X) {
            V = function (Y, Z, WW,XX,YY,ZZ) {
                if (Y && Z.indexOf('?') > -1 && ZZ = Z.substring(Z.indexOf('?') + 1)) {
                    YY = ZZ.indexOf('='),
                    WW = YY < 0 ? ZZ : ZZ.substring(0, YY);
                    XX = YY < 0 ? 'True' : ZZ.substring(YY + 1);
                    if (WW.toLowerCase() == Y.toLowerCase())
                        if (XX) {
                            XX = XX.toString().replace('+',' ');
                            return decodeURIComponent(XX);
                        }
                        return XX
                }
                return ''
            };
            W = '';
            d = d ? d : '';
            u = u ? u : window.location;
            if (u == 'f') window.top.location;
            while (p) {
                X = p.indexOf(',');
                X = X < 0 ? p.length : X;
                U = V(p.substring(0, X), u + '');
                if (U) U = U.indexOf('#') > -1 ? U.substring(0, U.indexOf('#')) : U;
                if (U) W += W ? d + U : U;
                p = p.substring(X == p.length ? X : X + 1)
            }
            return W
        };
    I = "search.about.com|terms|About.com>alltheweb.com|query,q|All The Web>altavista.co,altavista.de|q,r|AltaVista>.aol.,suche.aolsvc.de|q,query|AOL>ask.jp,ask.co|q,ask|Ask>www.baidu.com|wd|Baidu>business.com/search|query|Business.com>clix.pt|question|Clix>cuil.com|q|Cuil>daum.net,search.daum.net|q|Daum>eniro.|search_word|Eniro>goo.ne.jp,search.mobile.goo.ne.jp|MT|Goo (Jp.)>google.,googlesyndication.com|q,as_q|Google>icqit.com|q|icq>ixquick.com|query|ixquick>bing.com|q|Microsoft Bing>lycos.|query|Lycos>mail.ru/search,go.mail.ru/search|q|Mail.ru>bing.com|q|Microsoft Bing>myway.com|searchfor|MyWay.com>netscape.com|query,search|Netscape Search>reference.com|q|Reference.com>searchalot.com|query,q|Searchalot>seznam|w|Seznam.cz>busca.uol.com.br|q|UOL Busca>usseek.com|string|Usseek>virgilio.it|qs|Virgilio>web.de|su|Web.de>yahoo.com,yahoo.co.jp|p,va|Yahoo!>yandex|text|Yandex.ru>search.cnn.com|query|CNN Web Search>search.earthlink.net|q|Earthlink Search>search.comcast.net|q|Comcast Search>search.rr.com|qs|RoadRunner Search>optimum.net|q|Optimum Search";
    L = 0;
    
    if (e) {
        e = "_cm_dl";
        L = 1;
        if (r(e)) L = 0;
        if (!q(e, 1, new Date().setTime(new Date().getTime() + 1800000))) q(e, 1);
        if (!r(e)) L = 0;
    }
    
    g = (K ? K : document.referrer).toLowerCase();
    if (!g) h = 1;
    i = g.indexOf('?') > -1 ? g.indexOf('?') : g.length;
    j = g.substring(0, i);
    k = s(R.toLowerCase(), ',');
    for (m = 0; m < k.length; m++) {
        Q = j.indexOf(k[m]) == -1 ? '' : g;
        if (Q) O = Q;
    }
    
    if (!O && !h) {
        p = g;
        U = g.indexOf('//');
        X = g.indexOf('/', (U > -1 ? U + 2 : 0));
        t = g.substring((U > -1 ? U + 2 : 0), (X > -1 ? X : i)).toLowerCase();
        u = t;
        P = 'Referrers';
        S = I + '>' + J;
        if (d == 1) {
            j = B(j, 'oogle', '%');
            j = B(j, 'ahoo', '^');
            g = B(g, 'as_q', '*');
        }
        A = s(S, '>');
        for (i = 0; i < A.length; i++) {
            D = s(A[i], '|');
            E = s(D[0], ',');
            for (G = 0; G < E.length; G++) {
                H = j.indexOf(E[G]);
                if (H > -1) {
                    if (D[2]) N = u = D[2];
                    else N = t;
                    if (d == 1) {
                        N = B(N, '#', ' - ');
                        g = B(g, '*', 'as_q');
                        N = B(N, '^', 'ahoo');
                        N = B(N, '%', 'oogle');
                    }
                    i = s(D[1], ',');
                    for (k = 0; k < i.length; k++) {
                        if (g.split('?')[1] != undefined) {
                            M = F(i[k],"?"+g.split('?')[1]).toLowerCase();
                            if (M) break;
                        }
                    }
                }
            }
        }
    }
    
    if (!O) {
        O = F(W.toLowerCase(),DD) || F(W.toUpperCase(),DD);
        if (O) {
            u = O;
            if (M) P = 'Paid Search';
            else P = 'Paid Non-Search';
        }
        if (!O && N) {
            u = N;
            P = 'Natural Search'
        }
    }
    
    if (h == 1 && !O && L == 1) u = P = t = p = 'Direct Load';
    X = M + u + t;
    
    if (Z) {
        k = r('_cm');
        if (X) q('_cm', X);
        X = k ? '' : X;
    }
    
    if (f && X) {
        k = s(f, '>');
        for (m = 0; m < k.length; m++) {
            C = s(k[m], '|');
            S = s(C[1], ',');
            for (i = 0; i < S.length; i++) {
                if (j.indexOf(S[i].toLowerCase()) > -1) P = C[0];
            }
        }
    }
    
    if (l && X) {
        k = s(l, '>');
        for (m = 0; m < k.length; m++) {
            C = s(k[m], '|');
            S = s(C[1], ',');
            for (i = 0; i < S.length; i++) {
                if (F(S[i])) P = C[0];
            }
        }
    }
    
    if (n && X) {
        k = s(n, '>');
        for (m = 0; m < k.length; m++) {
            C = s(k[m], '|');
            S = s(C[1], ',');
            for (i = 0; i < S.length; i++) {
                h = O.toLowerCase();
                if (h.indexOf(S[i].toLowerCase()) == 0) P = C[0];
            }
        }
    }
    
    if (X) M = M ? M : N ? 'Keyword Unavailable' : 'n/a';
    
    b['_et_referrer'] =         X && p ? p : '';
    b['_et_referring_domain'] = X && t ? t : '';
    b['_et_partner'] =          X && N ? N : '';
    b['_et_campaign_id'] =      X && O ? O : '';
    b['_et_campaign'] =         X && u ? u : '';
    b['_et_keywords'] =         X && M ? M : '';
    b['_et_channel'] =          X && P ? P : '';
})(channel_domain,channel_parameter,channel_pattern,query_param,delimiter,referral_url_or,extra_search_engines,link_filters,direct_load,0,once_per_session);