0785d4b41a
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
20 lines
1.8 KiB
JavaScript
20 lines
1.8 KiB
JavaScript
// LinkSpin page tracking (external so pages carry a real CSP). (1) click-id passthrough: params on the page URL
|
|
// (clickid, subids, utm, lsid) ride onto every CTA link; (2) our own capture form gets the lsid; (3) a view /
|
|
// click beacon per page (no cookies, no personal data).
|
|
(function () {
|
|
var s = document.currentScript, slug = s && s.getAttribute('data-page'); if (!slug) return;
|
|
var P = {}, n = 0;
|
|
try { new URLSearchParams(location.search).forEach(function (v, k) { if (n < 20 && /^[a-zA-Z0-9_-]{1,32}$/.test(k)) { P[k] = String(v).slice(0, 200); n++; } }); } catch (e) {}
|
|
var lsid = /^[a-z0-9]{6,20}$/i.test(P.lsid || '') ? P.lsid : '';
|
|
document.querySelectorAll('a[data-cta]').forEach(function (a) {
|
|
try { var u = new URL(a.href); for (var k in P) if (!u.searchParams.has(k)) u.searchParams.set(k, P[k]); a.href = u.toString(); } catch (e) {}
|
|
// inside the ad viewer (a sandboxed frame with no top navigation) the button opens a new tab: an offer that refuses framing
|
|
// (X-Frame-Options: DENY) otherwise shows "refused to connect" in the frame (2026-11-23). Opened directly, the page is unchanged.
|
|
try { if (window.top !== window) { a.target = '_blank'; a.rel = 'noopener'; } } catch (e) { a.target = '_blank'; a.rel = 'noopener'; }
|
|
a.addEventListener('click', function () { try { navigator.sendBeacon('/api/p/' + slug + '/hit', new Blob([JSON.stringify({ k: 'cta' })], { type: 'application/json' })); } catch (e) {} });
|
|
});
|
|
// the built-in form (.ls-form) usually arrives with the lsid filled by the server; this is the fallback. A pasted
|
|
// provider form (.lsform) only gets it when the member's own form code carries an lsid field.
|
|
if (lsid) document.querySelectorAll('.ls-form input[name="lsid"], .lsform input[name="lsid"]').forEach(function (f) { if (!f.value) f.value = lsid; });
|
|
})();
|