Search code examples
javascriptgoogle-analyticsweb-analyticsuniversal-analytics

_u parameter in universal google analytics collect hits


When a hit is sent using Universal Analytics, it has the form:

http://www.google-analytics.com/collect?v=1&_v=j30&a=1944069884&t=pageview&_s=1&dl=http%3A%2F%2Fwww.website.com%2F&ul=en-us&de=iso-8859-1&dt=pageName&sd=24-bit&sr=1280x1024&vp=1280x417&je=1&_u=eKCAgEQiQ~&jid=&cid=1347711856.1411502373&tid=UA-XXXXXX-1&z=763679241

What is the bolded _u parameter for?


Solution

  • It appears to be an analytics of analytics. While analytics.js runs, single bits of a 48 bit long array (managed via function $c and it's prototype) are set.

    var vd=new $c;
    function J(a){
       vd.set(a)
    }
    

    For example bit 48 is set if the Linker Feature is used, bit 42 is set if window.navigator.sendBeacon is used to send a tracking beacon, bit 40 in case of transmission via XMLHttpRequest, bit 31 if a / has to be prepended to an extracted Path.

    var e=d.pathname||"";
    "/" != e.charAt(0) && ( J(31), e = "/" + e );
    

    8 Groups of 6 Bits are used to build a string out of the 64 Characters [A-z-_] postpended by tilde ~ and transmitted under the _u parameter.

    $c.prototype.encode = function(){
      //Group 6 bits to use a 64 Char Alphabet
      for(var tempArr=[], i=0; i < this.bitsArray.length; i++) {
        this.bitsArray[i] && (tempArr[Math.floor(i/6)] = tempArr[n.floor(b/6)] ^ 1 << i%6);
      }
    
      //Translate from 6 Bit groups to Alphabet
      for(i=0;i<tempArr.length; i++){
        tempArr[i]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".charAt(tempArr[i]||0);
      }
      return tempArr.join("")+"~";
    };
    

    If i've analysed the _u parameter correctly, decoding this string back to the individual bits would allow Google to identify if the corresponding features were used or points in the code were reached whilst running analytics.js