Skip to content

Instantly share code, notes, and snippets.

@nocodesupplyco
Last active January 2, 2023 20:18
Show Gist options
  • Save nocodesupplyco/cd032a57b608a615656bce8b5b24f5ca to your computer and use it in GitHub Desktop.
Save nocodesupplyco/cd032a57b608a615656bce8b5b24f5ca to your computer and use it in GitHub Desktop.
Get UTM Parameter Source From URL
// search the URL as a string
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
// do something if the URL has a specific parameter and it has a value
if (urlParams.has('utm_source') && urlParams.get('utm_source') > "") {
//...do something
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment