fix: 📈 record analytics when visitors agree instead of at next page load
Only recording at next page load loses the referrer where a visit originated from
This commit is contained in:
parent
55692154da
commit
02cb3bfc36
1 changed files with 14 additions and 9 deletions
|
@ -3,20 +3,25 @@ const yesBtn = ackeeBanner.querySelector('#yes');
|
||||||
const noBtn = ackeeBanner.querySelector('#no');
|
const noBtn = ackeeBanner.querySelector('#no');
|
||||||
const confirmKey = 'ackeeDetailed';
|
const confirmKey = 'ackeeDetailed';
|
||||||
|
|
||||||
yesBtn.addEventListener('click', () => localStorage.setItem(confirmKey, true));
|
const ackeeServer = 'https://ackee.sebin-nyshkim.net';
|
||||||
|
const ackeeDomainId = 'fc6deee5-c700-4c8a-87cd-421b673a33aa';
|
||||||
|
const ackeeOpts = { detailed: 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));
|
noBtn.addEventListener('click', () => localStorage.setItem(confirmKey, false));
|
||||||
|
|
||||||
if (localStorage.getItem(confirmKey) === null) {
|
if (localStorage.getItem(confirmKey) === null) {
|
||||||
ackeeBanner.show();
|
ackeeBanner.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
const ackeeServer = 'https://ackee.sebin-nyshkim.net';
|
|
||||||
const ackeeDomainId = 'fc6deee5-c700-4c8a-87cd-421b673a33aa';
|
|
||||||
const ackeeOpts = {
|
|
||||||
detailed: localStorage.getItem(confirmKey) === 'true'
|
|
||||||
};
|
|
||||||
|
|
||||||
if (localStorage.getItem(confirmKey) === 'true') {
|
if (localStorage.getItem(confirmKey) === 'true') {
|
||||||
const instance = ackeeTracker.create(ackeeServer, ackeeOpts);
|
record(ackeeServer, ackeeDomainId, ackeeOpts);
|
||||||
instance.record(ackeeDomainId);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue