eedc15bc13
The landing tag (t.js) adds the kept click id to links to linkspin.app, instantadpay.com and the share domains, also inside a member's own redirect link (Orlando's buttons are go.opgnetwerk.com/go?u=<encoded join link>). Spin and Banner Spin links are left alone and only LinkSpin's own id shapes travel. A spin link or Banner Spin pointed straight at those sites carries lsclk with no goal set up. netconv.js: new partner op 'events' on /api/partner/conv. Append-only ledger DATA_DIR/netconv.jsonl so two app copies cannot overwrite each other, marks.claim plus the ledger keys for once-only, join and wallet once per root click, every purchase by its own key, 30 days from click to event, the first account on a click owns it, the click owner's own account and own clicks kept as tests, each row keeps what the click was so later events survive the hit ageing out of the rotator. Spin events mirror into rotator.conv (replayed on a timer) so per-link counts, sources and placements see them; postbacks fire as for LinkSpin's own conversions. Reports > Conversions lists goals, joins, wallets, purchases, leads and partner postbacks with values, each once; per-link Conv. counts include goals. /join keeps lsclk as well as lsid. Guide, /conversions, privacy and chatbot (CANNED + FACTS) updated; reports.js and join.js tags bumped. The false Pages webhook claim is gone from chatbot.js, join.js and the home page: leads go to the member's list and CSV, or into a pasted autoresponder form. QA: bash qa/run.sh netconv (57 checks, also runs in member). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
108 lines
7.5 KiB
JavaScript
108 lines
7.5 KiB
JavaScript
/* LinkSpin landing tag (conversion pixel, 2026-10-23). Paste once on your landing page:
|
|
* <script async src="https://linkspin.app/t.js?px=YOUR_PIXEL_ID"></script>
|
|
* It reads the click id LinkSpin or InstantAdPay put on the link (lsclk, lsid or clickid in the address), keeps it on YOUR
|
|
* site for 30 days (localStorage + a first-party cookie, both named ls_clk), copies it into hidden form fields named lsclk,
|
|
* lsid or clickid, and adds it to links that stay on your site. Links to InstantAdPay and LinkSpin carry it too, also inside a
|
|
* redirect link of your own, so a sign-up or purchase there is counted on your click. Nothing personal is read or stored.
|
|
* It never throws and never blocks your page: every step is wrapped, and it only runs after the page has its scripts.
|
|
*/
|
|
(function () {
|
|
try {
|
|
var KEY = 'ls_clk', RX = /^[a-z0-9]{6,24}$/i, DAYS = 30, W = window;
|
|
var me = document.currentScript;
|
|
if (!me) { var all = document.getElementsByTagName('script'); for (var i = all.length - 1; i >= 0; i--) { if (/\/t\.js(\?|$)/.test(all[i].src || '')) { me = all[i]; break; } } }
|
|
if (!me || !me.src) return;
|
|
var src = new URL(me.src, location.href), base = src.origin, px = src.searchParams.get('px') || '';
|
|
var framed = true; try { framed = W.top !== W.self; } catch (e) { framed = true; }
|
|
var https = location.protocol === 'https:';
|
|
function setCookie(v) {
|
|
try { document.cookie = KEY + '=' + v + '; path=/; max-age=' + (DAYS * 86400) + (https ? (framed ? '; SameSite=None; Secure' : '; SameSite=Lax; Secure') : '; SameSite=Lax'); } catch (e) {}
|
|
}
|
|
function stored() {
|
|
var v = '';
|
|
try { var j = JSON.parse(W.localStorage.getItem(KEY) || 'null'); if (j && RX.test(j.id || '') && Date.now() - (j.ts || 0) < DAYS * 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;
|
|
}
|
|
function keep(v) { try { W.localStorage.setItem(KEY, JSON.stringify({ id: v, ts: Date.now() })); } catch (e) {} setCookie(v); }
|
|
var q = new URLSearchParams(location.search);
|
|
var fresh = q.get('lsclk') || q.get('lsid') || '';
|
|
var id = '';
|
|
if (RX.test(fresh)) { id = fresh; keep(id); }
|
|
else {
|
|
id = stored();
|
|
// a generic clickid only when we hold nothing better (it may be another network's id)
|
|
var g = q.get('clickid') || ''; if (!id && RX.test(g)) { id = g; keep(id); fresh = g; }
|
|
}
|
|
// tell LinkSpin the landing happened (sets its own 30-day cookie and the 24 h match); only for a fresh id
|
|
if (fresh && RX.test(fresh) && /^px[a-f0-9]{10}$/.test(px)) { try { var im = new Image(1, 1); im.src = base + '/t.gif?px=' + px + '&c=' + encodeURIComponent(fresh) + '&r=' + Math.random().toString(36).slice(2, 8); } catch (e) {} }
|
|
var LS = W.LinkSpin = W.LinkSpin || {};
|
|
LS.clickId = function () { return id || stored(); };
|
|
LS.goal = function (pixelId, name, value) {
|
|
try {
|
|
var c = id || stored(); var u = base + '/cv.gif?px=' + encodeURIComponent(pixelId) + (name ? '&goal=' + encodeURIComponent(name) : '') + (value != null && value !== '' ? '&value=' + encodeURIComponent(value) : '') + (c ? '&c=' + encodeURIComponent(c) + '&m=stored' : '') + '&r=' + Math.random().toString(36).slice(2, 8);
|
|
var im2 = new Image(1, 1); im2.src = u;
|
|
} catch (e) {}
|
|
};
|
|
if (!id) return;
|
|
var NAMES = ['lsclk', 'lsid', 'clickid'];
|
|
function fillForms(root) {
|
|
try {
|
|
var f = (root || document).querySelectorAll('input[name="lsclk"],input[name="lsid"],input[name="clickid"]');
|
|
for (var i = 0; i < f.length; i++) if (!f[i].value) f[i].value = id;
|
|
} catch (e) {}
|
|
}
|
|
fillForms();
|
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', function () { fillForms(); });
|
|
document.addEventListener('submit', function (e) { fillForms(e.target); }, true);
|
|
var host = location.hostname.replace(/^www\./, '');
|
|
function decorate(a) {
|
|
try {
|
|
if (!a || !a.href || a.getAttribute('data-ls-skip') != null) return;
|
|
var u = new URL(a.href, location.href);
|
|
if (!/^https?:$/.test(u.protocol) || u.hostname.replace(/^www\./, '') !== host) return;
|
|
if (u.pathname === location.pathname && u.search === location.search && u.hash) return; // an anchor on this page
|
|
for (var i = 0; i < NAMES.length; i++) if (u.searchParams.has(NAMES[i])) return;
|
|
u.searchParams.set('lsclk', id); a.href = u.toString();
|
|
} catch (e) {}
|
|
}
|
|
// links to the network (2026-11-07): a bridge page's button carries the click to InstantAdPay or LinkSpin, which report sign-ups
|
|
// and purchases against it. Also inside a redirect link of the member's own (go.example.com/go?u=https%3A%2F%2Finstantadpay.com...):
|
|
// only that one parameter is rewritten, every other one keeps its exact encoding. Spin and Banner Spin links are left alone, they
|
|
// make their own click. Only LinkSpin's own id shapes travel, never another network's clickid. Done on load, again when the page
|
|
// is ready and at the click, so a page script that rewrites its links first or later does not lose it.
|
|
var NET = /*ls-net*/["linkspin.app","instantadpay.com","instantadpay.link","ctbgo.com","mylinehq.com"]/*ls-net*/;
|
|
var OURS = /^(?:[a-f0-9]{10}|[aik][a-f0-9]{11})$/;
|
|
function netUrl(s) {
|
|
try { var u = new URL(s); return /^https?:$/.test(u.protocol) && NET.indexOf(u.hostname.toLowerCase().replace(/^www\./, '')) >= 0 && !/^\/(r|c|i)\//.test(u.pathname) ? u : null; } catch (e) { return null; }
|
|
}
|
|
function carries(u) { for (var i = 0; i < NAMES.length; i++) if (u.searchParams.has(NAMES[i])) return true; return false; }
|
|
function addId(s) { var h = s.indexOf('#'), b = h < 0 ? s : s.slice(0, h), t = h < 0 ? '' : s.slice(h); return b + (b.indexOf('?') < 0 ? '?' : /[?&]$/.test(b) ? '' : '&') + 'lsclk=' + encodeURIComponent(id) + t; }
|
|
function network(a) {
|
|
try {
|
|
if (!OURS.test(id) || a.getAttribute('data-ls-skip') != null) return false;
|
|
var href = a.href, n = netUrl(href);
|
|
if (n) { if (!carries(n)) a.href = addId(href); return true; }
|
|
var u = new URL(href); if (!/^https?:$/.test(u.protocol) || !u.search) return false;
|
|
var parts = u.search.slice(1).split('&'), found = false, changed = false;
|
|
for (var i = 0; i < parts.length; i++) {
|
|
var eq = parts[i].indexOf('='); if (eq < 1) continue;
|
|
var v; try { v = decodeURIComponent(parts[i].slice(eq + 1).replace(/\+/g, ' ')); } catch (e) { continue; }
|
|
var inner = /^https?:/i.test(v) ? netUrl(v) : null; if (!inner) continue;
|
|
found = true; if (carries(inner)) continue;
|
|
parts[i] = parts[i].slice(0, eq + 1) + encodeURIComponent(addId(v)); changed = true;
|
|
}
|
|
if (changed) a.href = href.slice(0, href.indexOf('?') + 1) + parts.join('&') + (u.hash || '');
|
|
return found;
|
|
} catch (e) { return false; }
|
|
}
|
|
function sweep() { try { var l = document.querySelectorAll('a[href]'); for (var i = 0; i < l.length; i++) network(l[i]); } catch (e) {} }
|
|
sweep();
|
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', sweep);
|
|
W.addEventListener('load', sweep);
|
|
function onClick(e) { try { var a = e.target && e.target.closest ? e.target.closest('a[href]') : null; if (a && !network(a)) decorate(a); } catch (er) {} }
|
|
document.addEventListener('click', onClick, true);
|
|
document.addEventListener('auxclick', onClick, true);
|
|
} catch (e) { /* never break the member's page */ }
|
|
})();
|