Hi! I’m looking to do the following function:
$('#unique-popup').addClass('is-active');
But have it only run when a UTM is present. E.g.
utm-source=301
Thank you!
Hi! I’m looking to do the following function:
$('#unique-popup').addClass('is-active');
But have it only run when a UTM is present. E.g.
utm-source=301
Thank you!
Hi @Jorge1, found a thread on SO that might be of interest: arrays - How can I get specific items from a URL in Javascript? - Stack Overflow
Based on what they say here, you could potentially use something like the following. Though I’m only guessing:
const url = new URL(window.location.href);
const utm_source = (url.searchParams.get("utm_source"));
Then, I guess:
if (utm_source === "301") {
$('#unique-popup').addClass('is-active');
}
So, like this?
document.addEventListener("DOMContentLoaded", function() {
const url = new URL(window.location.href);
const utm_source = (url.searchParams.get("utm_source"));
if (utm_source === "301") {
$('#unique-popup').addClass('is-active');
}
});