Skip to content

Commit 503d3b7

Browse files
committed
pass referrer data
1 parent 87675d9 commit 503d3b7

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

packages/script/src/index.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,23 @@
225225
body: JSON.stringify({
226226
domain: siteDomain,
227227
url: window.location.href,
228+
referrer: document.referrer,
228229
}),
229-
}).then(async (res) => {
230-
if (!res.ok) {
231-
const { error } = await res.json();
232-
console.error(
233-
`[Dub Analytics] Failed to track visit: ${error.message}`,
234-
);
235-
return;
236-
}
237-
const { clickId } = await res.json(); // Response: { clickId: string }
238-
setCookie(CLICK_ID, clickId, cookieOptions);
239-
});
230+
})
231+
.then(async (res) => {
232+
if (!res.ok) {
233+
const { error } = await res.json();
234+
console.error(
235+
`[Dub Analytics] Failed to track visit: ${error.message}`,
236+
);
237+
return;
238+
}
239+
const { clickId } = await res.json(); // Response: { clickId: string }
240+
setCookie(CLICK_ID, clickId, cookieOptions);
241+
})
242+
.catch((error) => {
243+
console.error('[Dub Analytics] Failed to track visit:', error);
244+
});
240245
}
241246
}
242247

0 commit comments

Comments
 (0)