f6621a8e34
B2: the built-in page form posted an empty lsid (pt.js only filled .lsform, the pasted-form class), so page leads never
reached the rotator 'lead' conversion or the postback. The server now fills the hidden lsid at render from ?lsid or the
ls.click cookie, the lead POST falls back to the ls.click cookie when the form sends none, and pt.js fills both .ls-form
and .lsform as a fallback (cache tag pt.js?v=2). Pasted provider forms get no added field: some providers reject unknown
fields, so the lsid only rides along when the member's own form code has an lsid field.
B4: /p.gif now stores the pixel's e= event name (lowercase [a-z0-9_-]{1,32}) in a parallel ev map in audiences.json;
hits stay plain timestamps, so old rows count, match and prune as before. The audiences list shows counts by event
(events for cookie visitors, eventsSoft for 24 h soft keys).
B3: a pixel hit with no ls.vid cookie still offers the cookie but is counted under the 24 h IP + user agent key only,
not a fresh 30-day visitor id, so a cookie-blocking browser counts once.
Test: qa/lsid-pixel.test.mjs (bash qa/run.sh lsid), unit + local end to end on a throwaway data dir.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17 lines
1.4 KiB
JavaScript
17 lines
1.4 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) {}
|
|
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; });
|
|
})();
|