Skip to content

Instantly share code, notes, and snippets.

@maestrojed
Created September 9, 2020 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maestrojed/278fca350e936b00abe5bc20368c8095 to your computer and use it in GitHub Desktop.
Save maestrojed/278fca350e936b00abe5bc20368c8095 to your computer and use it in GitHub Desktop.
// Look for and use Linkwell Source, Medium, and Campaign parameters. Override any UTM data
sourceParam = new RegExp('[\?&]source=([^&#]*)').exec(window.location.href);
if (sourceParam !== null){
var source = "";
source = decodeURI(sourceParam[1]) || 0;
ga('set', 'campaignSource', source);
}
mediumParam = new RegExp('[\?&]medium=([^&#]*)').exec(window.location.href);
if (mediumParam !== null){
var medium = "";
medium = decodeURI(mediumParam[1]) || 0;
ga('set', 'campaignMedium', medium);
}
campaignParam = new RegExp('[\?&]campaign=([^&#]*)').exec(window.location.href);
if (campaignParam !== null){
var campaign = "";
campaign = decodeURI(campaignParam[1]) || 0;
ga('set', 'campaignName', campaign);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment