try to save referrer to local storage

This commit is contained in:
Viet-Tien Ngoc 2024-10-01 10:01:06 +02:00
parent 6f532d6902
commit 7ec87553cc

View file

@ -264,6 +264,18 @@
let cache;
let initialized;
// Save referrer
if (currentRef && localStorage) {
try {
const { hostname: refHostname } = new URL(currentRef);
if (refHostname !== hostname) {
localStorage.setItem('umami.referrer', currentRef);
}
} catch (e) {
/* empty */
}
}
if (autoTrack && !trackingDisabled()) {
if (document.readyState === 'complete') {
init();