Skip to content

Instantly share code, notes, and snippets.

@ericakfranz
Created February 26, 2022 16:16
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 ericakfranz/f4eb0f109d103e62749f073c6312c497 to your computer and use it in GitHub Desktop.
Save ericakfranz/f4eb0f109d103e62749f073c6312c497 to your computer and use it in GitHub Desktop.
Check if the URL already contains a query argument and choose whether to output a '?' or '&' character before any other string.
function mySep() {
var url = window.location.href;
if (url.indexOf('?') != -1) {
var sep = '&';
} else var sep = '?';
console.log(sep);
return sep;
}
mySep();
const addSep = mySep();
// custom smart tag in OM
document.addEventListener('om.Dtr.init', function (event) {
event.detail.Dtr.setCustomVariable('separator', addSep);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment