Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active February 26, 2024 21:40
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 cliffordp/f4aa43badd4d99cee537a82ff0e5ab3b to your computer and use it in GitHub Desktop.
Save cliffordp/f4aa43badd4d99cee537a82ff0e5ab3b to your computer and use it in GitHub Desktop.
// UNNECESSARY. DO NOT USE.
// Do this instead: https://help.gohighlevel.com/support/solutions/articles/48001172004
<script id="bizname-enforce-default-url-query-param">
// Source: https://gist.github.com/cliffordp/f4aa43badd4d99cee537a82ff0e5ab3b
// Video: https://youtu.be/MHKzHf1BhrY
// Function to check for the 'bizname' query parameter and redirect if not present.
(function enforceDefaultBiznameQueryParam() {
const urlParams = new URLSearchParams(window.location.search);
const bizname = urlParams.get('bizname');
// If 'bizname' query param is not present or is an empty string, redirect.
if (bizname === null || bizname.trim() === '') {
// Construct the new URL with the default 'bizname' query parameter.
const currentUrl = new URL(window.location.href);
currentUrl.searchParams.set('bizname', 'Your Business Name');
window.location.href = currentUrl.toString();
}
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment