Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/script/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(function () {
const CLICK_ID = 'dub_id';
const OLD_CLICK_ID = 'dclid';
const COOKIE_EXPIRES = 90 * 24 * 60 * 60 * 1000; // 90 days
const HOSTNAME = window.location.hostname;

Expand Down Expand Up @@ -108,14 +107,13 @@
function checkCookieAndSet(clickId) {
const { cookieOptions, attributionModel } = getOptions(script);

const cookie = getCookie(CLICK_ID) || getCookie(OLD_CLICK_ID);
const cookie = getCookie(CLICK_ID);

// If the cookie is not set
// or the cookie is set and is not the same as the clickId + attribution model is 'last-click'
// then set the cookie
if (!cookie || (cookie !== clickId && attributionModel === 'last-click')) {
setCookie(CLICK_ID, clickId, cookieOptions);
setCookie(OLD_CLICK_ID, clickId, cookieOptions);
}
}

Expand All @@ -125,7 +123,7 @@
const { apiHost, shortDomain, queryParam } = getOptions(script);

// When the clickId is present in the URL, set the cookie (?dub_id=...)
let clickId = searchParams.get(CLICK_ID) || searchParams.get(OLD_CLICK_ID);
const clickId = searchParams.get(CLICK_ID);

if (clickId) {
checkCookieAndSet(clickId);
Expand Down
Loading