Files

35 lines
2.1 KiB
JavaScript

/* LinkSpin goal pixel, script version (conversion pixel, 2026-10-23). Paste on your thank-you page:
* <script async src="https://linkspin.app/cv.js?px=YOUR_PIXEL_ID&goal=subscriber"></script> (optional &value=19.95)
* It sends the click id from this page's address, or the one the landing tag (t.js) kept on your site, to LinkSpin.
* The image version (cv.gif) works without scripts; this one is surer because it can read what the landing tag kept.
* It never throws and never blocks your page.
*/
(function () {
try {
var RX = /^[a-z0-9]{6,24}$/i, W = window;
function stored() {
var v = '';
try { var j = JSON.parse(W.localStorage.getItem('ls_clk') || 'null'); if (j && RX.test(j.id || '') && Date.now() - (j.ts || 0) < 30 * 864e5) v = j.id; } catch (e) {}
if (!v) { try { var m = /(?:^|;\s*)ls_clk=([a-z0-9]{6,24})/i.exec(document.cookie || ''); if (m) v = m[1]; } catch (e) {} }
return v;
}
var q = new URLSearchParams(location.search);
var inUrl = q.get('lsclk') || q.get('lsid') || q.get('clickid') || '';
var c = '', m = '';
if (RX.test(inUrl)) { c = inUrl; m = 'url'; } else { c = stored(); m = c ? 'stored' : ''; }
var list = document.getElementsByTagName('script');
for (var i = 0; i < list.length; i++) {
var s = list[i];
try {
if (!/\/cv\.js(\?|$)/.test(s.src || '') || s.getAttribute('data-ls-done')) continue;
s.setAttribute('data-ls-done', '1');
var u = new URL(s.src, location.href), px = u.searchParams.get('px') || '';
if (!/^px[a-f0-9]{10}$/.test(px)) continue;
var goal = u.searchParams.get('goal') || '', value = u.searchParams.get('value');
var out = u.origin + '/cv.gif?px=' + px + (goal ? '&goal=' + encodeURIComponent(goal) : '') + (value != null && value !== '' ? '&value=' + encodeURIComponent(value) : '') + (c ? '&c=' + encodeURIComponent(c) + '&m=' + m : '') + (u.searchParams.get('test') === '1' ? '&test=1' : '') + '&r=' + Math.random().toString(36).slice(2, 8);
var im = new Image(1, 1); im.src = out;
} catch (e) {}
}
} catch (e) { /* never break the member's page */ }
})();