Skip to content

Instantly share code, notes, and snippets.

@Angelfire
Last active January 29, 2019 17:47
Show Gist options
  • Save Angelfire/80d376da7681642b422f to your computer and use it in GitHub Desktop.
Save Angelfire/80d376da7681642b422f to your computer and use it in GitHub Desktop.
strip url UTM
var obj = {};
var strUTM = "https://myapp.com/?utm_source=Facebook&utm_medium=Social&utm_term=pinned-post&utm_content=First-Post-Philly&utm_campaign=Philly-Launch";
strUTM.replace(/^.+\?/, '').split('&').forEach(function (i) { obj[i.split('=')[0]] = i.split('=')[1] })
/*
Object {
utm_source: "Facebook",
utm_medium: "Social",
utm_term: "pinned-post",
utm_content: "First-Post-Philly",
utm_campaign: "Philly-Launch"
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment