Created
December 25, 2013 15:59
-
-
Save noff/8124475 to your computer and use it in GitHub Desktop.
parse utm'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
var source = ''; | |
var medium = ''; | |
var campaign = ''; | |
var q = document.location.search; | |
q = q.substring(1,q.length); | |
q = q.split('&'); | |
for(var a in q) { | |
if (q.hasOwnProperty(a)){ | |
var b = q.split(''); | |
if(b[0] == 'utm_source' ) { | |
source = b[1]; | |
} | |
if(b[0] == 'utm_medium' ) { | |
medium = b[1]; | |
} | |
if(b[0] == 'utm_campaign' ) { | |
campaign = b[1]; | |
} | |
} | |
} | |
mixpanel.track("Lead", { | |
utm_source: source, | |
utm_medium: medium, | |
utm_campaign: campaign, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This shows up high on google SERP, and it is invalid code...
You might be better off with: