Created
August 15, 2011 18:16
-
-
Save tobiassjosten/1147343 to your computer and use it in GitHub Desktop.
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
(function(_gaq) { | |
var path = location.pathname, | |
languages = ['en', 'sv']; | |
// We want prefix == 'en|sv|etc' or null. | |
var prefix = path.match(/^\/([a-z]{2})(\/.+)?$/), | |
prefix = prefix ? prefix[1] : null; | |
if (prefix && languages.indexOf(prefix) >= 0) { | |
// If we are on '/en|sv|etc', fallback to '/'. | |
var path_strip = '/' + prefix; | |
path = path == path_strip ? '/' : path.replace(path_strip, ''); | |
_gaq.push(['_setCustomVar', 1, 'Language', prefix, 3]); | |
} | |
_gaq.push(['_trackPageview', path]); | |
})(_gaq); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment