Drop the referral token from the links. Add some means of identifying the links from Javascript.
Eg:
<a href="http://example.com/program" class="-js-referral-link">Get Started</a>
Then use
querySelectorAll
to find the links and update them:
const referralTokenValue = 123456789;
const referralLinks = document.querySelectorAll("a.-js-referral-link");
for (let a of referralLinks){
const url = new URL(a.href);
url.searchParams.set("referralToken", referralTokenValue);
a.href = url.toString();
}
Demo[
^]