fix: 📈 record analytics when visitors agree instead of next page load

Only recording at next page load loses the referrer where a visit originated from
This commit is contained in:
Sebin Nyshkim 2025-07-28 18:31:52 +02:00
parent b322ef9759
commit 89b004c262
Signed by: SebinNyshkim
SSH key fingerprint: SHA256:LG1WHMySL/4iW/Yci+0eHgbf0te5beRiLlmyoY8E5D0

View file

@ -10,7 +10,15 @@
const ackeeDomainId = 'e60cc3de-916c-424c-ac6e-2fd43d41e240';
const ackeeOpts = { detailed: true };
yesBtn.addEventListener('click', () => localStorage.setItem(confirmKey, true));
const record = (server, domainId, options) => {
const instance = ackeeTracker.create(server, options);
instance.record(domainId);
};
yesBtn.addEventListener('click', () => {
localStorage.setItem(confirmKey, true);
record(ackeeServer, ackeeDomainId, ackeeOpts);
});
noBtn.addEventListener('click', () => localStorage.setItem(confirmKey, false));
if (localStorage.getItem(confirmKey) === null) {
@ -18,8 +26,7 @@
}
if (localStorage.getItem(confirmKey) === 'true') {
const instance = ackeeTracker.create(ackeeServer, ackeeOpts);
instance.record(ackeeDomainId);
record(ackeeServer, ackeeDomainId, ackeeOpts);
}
</script>