Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
track cloudflare's edge location by using GA event
<script>
(function(){
var request = new XMLHttpRequest();
request.open('GET', '/cdn-cgi/trace', true);
request.onload = function() {
if (request.status != 200) return;
var match = request.responseText.match(/(colo|loc)=(\w+)/g),
colo = match[0].split('=')[1], loc = match[1].split('=')[1];
ga('send', 'event', 'cloudflare', loc, colo);
};
request.send();
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.