czwartek, lutego 17, 2011

UTMU Google Analytics Request Parameter

During creation of backend PHP component to track page views with use Google Analytics without user knowledge I have encountered interesting problem. GIF request contains parameter which seems to be unrelated to page or view parameters. I have analyzed ga.js code and found that this parameter is created basing on table filled with true/false values. Nothing less, nothing more. Only true/false.

Code responsible for creation of utmu parameter basing on this table can be presented in this form (distributed on WTFPL license):

var usage = []; function setUsage(index) { usage[index] = true; }; function getUsage() { var allChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; var temp = []; for (h = 0; h < usage.length; h++) if (usage[h]) { temp[Math.floor(h / 6)] ^= 1 << h % 6; } for (h = 0; h < temp.length; h++) temp[h] = allChars.charAt(temp[h] || 0); return temp.join("") };
It's looks like that above parameter is not required or validated, it is used only for statistical purposes (analytics inside of analytics). List of functions with their codes found in ga.js file:
FunctionCode
_addIgnoredOrganic15
_addIgnoredRef31
_addItem19
_addOrganic14
_addTrans21
_anonymizeIp70
_clearIgnoredOrganic16
_clearIgnoredRef32
_clearOrganic17
_clearXKey72
_clearXValue73
_cookiePathCopy30
_createAsyncTracker33
_createEventTracker74
_createTracker55
_createXObj75
_deleteCustomVar35
_getAccount64
_getAsyncTracker34
_getClientInfo53
_getDetectFlash65
_getDetectTitle56
_getLinkerUrl52
_getLocalGifPath57
_getName58
_getServiceMode59
_getTrackerByName51
_getTracker0
_getVersion60
_getVisitorCustomVar50
_getXKey76
_getXValue77
_initData2
_linkByPost13
_link12
_sendXEvent78
_setAccount3
_setAllowAnchor7
_setAllowHash8
_setAllowLinker11
_setAutoTrackOutbound79
_setCampaignCookieTimeout29
_setCampaignTrack36
_setCampCIdKey37
_setCampContentKey38
_setCampIdKey39
_setCampMediumKey40
_setCampNameKey41
_setCampNOKey42
_setCampSourceKey43
_setCampTermKey44
_setClientInfo66
_setCookiePath9
_setCookiePersistence24
_setCookieTimeout25
_setCustomVar10
_setDetectFlash61
_setDetectTitle62
_setDomainName6
_setHrefExamineLimit80
_setLocalGifPath46
_setLocalRemoteServerMode47
_setLocalServerMode92
_setMaxCustomVariables71
_setNamespace48
_setReferrerOverride49
_setRemoteServerMode63
_setSampleRate45
_setSessionCookieTimeout26
_setSessionTimeout27
_setTrackOutboundSubdomains81
_setTransactionDelim82
_setTrans20
_setVar22
_setVisitorCookieTimeout28
_setXKey83
_setXValue84
_trackEvent4
_trackPageview1
_trackTrans18
_visitCode54

It is important to mention that, like everything else this code is not guaranteed to always work as it has been described by me. Google can change this anytime in the way which fit they needs the best. When it is currently not checked it can be checked against validity in the future.

2 komentarze:

Thomas Bachem pisze...

Jakub, thanks for the analysis!

You can use my http://code.google.com/p/php-ga/ project for the backend tracking btw.

Anonimowy pisze...

Thanks! I wish to find your lib before creating my own. It is very nice.

Prześlij komentarz