Skip to content

Instantly share code, notes, and snippets.

@kohiomobz
Created May 27, 2015 00:12
Show Gist options
  • Save kohiomobz/b920ff837c889fee9bff to your computer and use it in GitHub Desktop.
Save kohiomobz/b920ff837c889fee9bff to your computer and use it in GitHub Desktop.
Getting URL Parameters
function campaignParams() {
var campaign_keywords = 'utm_source utm_medium utm_campaign utm_content utm_term'.split(' ')
, kw = ''
, params = {}
, first_params = {} ;
var index;
for (index = 0; index < campaign_keywords.length; ++index) {
kw = getQueryParam(document.URL, campaign_keywords[index]);
if (kw.length) {
params[campaign_keywords[index] + ' [last touch]'] = kw;
}
}
for (index = 0; index < campaign_keywords.length; ++index) {
kw = getQueryParam(document.URL, campaign_keywords[index]);
if (kw.length) {
first_params[campaign_keywords[index] + ' [first touch]'] = kw;
}
}
mixpanel.register(params);
mixpanel.people.set(params);
mixpanel.register_once(first_params);
mixpanel.people.set_once(first_params);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment