This commit is contained in:
oliver committed 2026-10-17 10:40:05 -03:00
1 parent 575e3efece
commit b4e0faa62e
2 files changed
+70 -3

No files matched your search

+36
View File
@@ -342,6 +342,41 @@
powerhouse: 5,
};
// ── UTM tracking (source / medium / campaign) ─────────────────────────────
const UTM_KEYS = ["source", "medium", "campaign"];
function getCookie(name) {
const match = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));
return match ? decodeURIComponent(match[2]) : null;
}
function setCookie(name, value, days) {
const date = new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
document.cookie =
name + "=" + encodeURIComponent(value) +
"; expires=" + date.toUTCString() +
"; path=/; SameSite=Lax";
}
UTM_KEYS.forEach(function (key) {
const val = params.get("utm_" + key);
if (val) setCookie("utm_" + key, val, 90);
});
function appendUTM(form) {
UTM_KEYS.forEach(function (key) {
const val = getCookie("utm_" + key);
if (val) {
const input = document.createElement("input");
input.type = "hidden";
input.name = "utm_" + key;
input.value = val;
form.appendChild(input);
}
});
}
// ── Buy handler ───────────────────────────────────────────────────────────
function buyProduct(productId) {
if (!uuid) {
@@ -369,6 +404,7 @@
clear.name = "clear";
clear.value = "1";
form.appendChild(clear);
appendUTM(form);
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);