w-funnel/src/shared/utils/cookies.ts
gofnnp 90126bbf3b special-offer
add special offer page
2025-10-10 19:57:46 +04:00

32 lines
667 B
TypeScript

export function getTrackingCookiesForRedirect() {
const cookieObj = Object.fromEntries(
document.cookie.split("; ").map((c) => c.split("="))
);
const result = Object.entries(cookieObj).filter(([key]) => {
return (
[
"_fbc",
"_fbp",
"_ym_uid",
"_ym_d",
"_ym_isad",
"_ym_visorc",
"yandexuid",
"ymex",
].includes(key) ||
key.startsWith("_ga") ||
key.startsWith("_gid")
);
});
const queryString = result
.map(
([key, value]) =>
`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
)
.join("&");
return queryString;
}