Created
May 27, 2014 14:32
-
-
Save digdeep/15b7d68b36e2bdb765f1 to your computer and use it in GitHub Desktop.
GA_VID_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
<script> | |
var clientId = ga.getAll()[0].get('clientId'); | |
dataLayer.push({ | |
'UAID': clientId, | |
'event': 'UAID' | |
}); | |
</script> |
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
// Extracts the Visitor ID from a GA cookie written by @craig552uk github | |
function _goog_id(){ | |
var id, a, c = document.cookie.split('; '); | |
for(i in c){a = c[i].split('=');if(a[0]=='__utma'){id = a[1].split('.')[1];}} | |
return id || 'unknown'; | |
} | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', 'UA-XXXXX-X']); | |
_gaq.push(['_trackPageview']); | |
_gaq.push(function(){_gaq.push(['_setCustomVar',5,'VisitorID',_goog_id(),1]);}); | |
(function() { | |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); | |
})(); |
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
/* Google Analytics UTM ID written by Tim Griffin */ | |
$(function() { | |
function _uxGetCookie(c_name) { | |
var c_value = document.cookie; | |
var c_start = c_value.indexOf(" " + c_name + "="); | |
if (c_start == -1) c_start = c_value.indexOf(c_name + "="); | |
if (c_start == -1) { | |
c_value = null; | |
} else { | |
c_start = c_value.indexOf("=", c_start) + 1; | |
var c_end = c_value.indexOf(";", c_start); | |
if (c_end == -1) { | |
c_end = c_value.length; | |
} | |
c_value = unescape(c_value.substring(c_start, c_end)); | |
} | |
return c_value; | |
} | |
if (_uxGetCookie('_utma')) { | |
var utma = _uxGetCookie('_utma').split('.'); | |
_gaq.push(['_setCustomVar', 1, 'UTM ID', utma[1] + '.' + utma[2], 1]); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment