Conversion tracking fixes (Marty approved 2026-10-26): own clicks are tests on every click type, Banner Spin straight-to-page clicks carry lsclk
1. Own clicks: a goal owner's own click on ANY click type (LinkSpin/InstantAdPay ads, spin links, Banner Spins) is kept as a test, never counted, never fires a goal postback. Own = ad click flagged self for that owner, a spin-link / Banner Spin click marked at click time (signed in as the owner, or from an owner soft key: markOwnClick in server.js), or the clicking or converting browser's soft key is one the owner signs in from. auth.onSeen notes LinkSpin session soft keys (throttled, kept 31 days in convtrack.json S.own); /api/partner/clicks takes owners [{owner, sk, ts}] from InstantAdPay before the clicks, so IAP members' own browsers are known too. Linked positions share the owner's email. X-LS-Result adds ;self. partnerSummary returns selfTests for the IAP card. Conversions screen copy: test with Send a test conversion and the &test=1 page check, own clicks never count (conversions.js ?v=20261026a).
3. Banner Spin: a click whose target is a direct page (not a /r/ spin link) gets ?lsclk=<k click id> when the owner tracks goals (string insert like lsconv.withClickId: params kept, before #hash, an existing lsclk never replaced). convtrack.lookup resolves k ids through bannerspin.clickById; conversions record k:'bspin' with the Banner Spin, banner, page and source; report By Banner Spin, CSV site 'Banner Spin', postback ctx with its sub ids.
Guides: /conversion-tracking (Banner Spin straight to a page now counted, own clicks on every type are tests, By Banner Spin), /refuel tile. Chatbot CANNED + FACTS, KNOWLEDGE_DATE 2026-10-26.
QA: convpixel 77/77 (new: owner soft keys, own ad/spin/Banner Spin/IAP clicks as tests, stranger still counts, own-browser conversion, withClickId, Banner Spin lsclk + By Banner Spin + spin-link banner untouched, selfTests in the IAP summary, no postback for own clicks); lsid 31/31; fuel all pass (engine.js / engine-room.js / kit.js untouched, byte-identical with InstantAdPay); bannerspin 75/75; member walk 0 bugs; public 0 bugs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -687,14 +687,15 @@ async function boot() {
|
||||
setInterval(() => iapsync.tick().catch(e => console.error('iapsync', e.message)), 2 * 60 * 1000);
|
||||
const ownHosts = () => [SITE_HOST].concat(String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean), pagesHost() ? [pagesHost()] : []);
|
||||
rotator.init({ dataDir: DATA_DIR, geo, ownHosts, sources, wantsClickId: owner => convtrack.goalsOf(owner).length > 0 });
|
||||
convtrack.init({ dataDir: DATA_DIR, rotator, campaignOf: id => ads.campaignById(id) });
|
||||
convtrack.init({ dataDir: DATA_DIR, rotator, bannerspin, campaignOf: id => ads.campaignById(id) });
|
||||
auth.onSeen((email, req) => convtrack.noteSession(email, req)); // own-click tests (2026-10-26): the soft keys a member signs in from
|
||||
// destination health: every 30 min, first pass 2 min after boot; a pause lands in the owner's on-site inbox (same path as the payment notices)
|
||||
health.init({ rotator, bannerspin, dataDir: DATA_DIR, notify: (email, subject, html) => messages.deliver(1, ADMIN_EMAIL || 'house@' + SITE_HOST, [email], subject, html) });
|
||||
setTimeout(() => health.tick().catch(e => console.error('health', e.message)), 2 * 60 * 1000);
|
||||
setInterval(() => health.tick().catch(e => console.error('health', e.message)), 30 * 60 * 1000);
|
||||
setInterval(() => { try { rotator.sweepDemos(); } catch (e) {} }, 60 * 60 * 1000); // unclaimed home-page demo spins expire after 24 h
|
||||
postbacks.init({ dataDir: DATA_DIR, ownHosts, rotator, sources });
|
||||
bannerspin.init({ dataDir: DATA_DIR, uploadsDir: UPLOADS_DIR, rotator, geo, sources, ownHosts, adminEmail: ADMIN_EMAIL, facts: bannerFacts });
|
||||
bannerspin.init({ dataDir: DATA_DIR, uploadsDir: UPLOADS_DIR, rotator, geo, sources, ownHosts, adminEmail: ADMIN_EMAIL, facts: bannerFacts, wantsClickId: owner => convtrack.goalsOf(owner).length > 0, withClickId: convtrack.withClickId });
|
||||
rotator.setExternalConvert((lsid, ev, facts) => bannerspin.convert(lsid, ev, facts)); // Banner Spin click ids convert like spin-link clicks
|
||||
sources.init({ dataDir: DATA_DIR, postbacks, rotator, catalogFile: path.join(ROOT, 'catalog', 'traffic-sources.json'), linkHost: () => { const hs = String(siteConfig().linkDomains || '').split(',').map(x => x.trim()).filter(Boolean); return hs[0] || SITE_HOST; } });
|
||||
zones.init({ dataDir: DATA_DIR, ads, siteHost: SITE_HOST });
|
||||
@@ -847,6 +848,15 @@ function clickCookie(id) { return 'ls.clk=' + id + '; Path=/; Max-Age=2592000; '
|
||||
// an ad click: record a click id for the campaign and append ?lsclk=<id> to the target (existing params kept, an lsclk
|
||||
// already there left alone). A spin-link target passes it on, so the spin-link click inherits the ad as its source.
|
||||
// Never blocks the click: on any failure the visitor goes to the target unchanged.
|
||||
// a spin-link or Banner Spin click by its owner (signed in here, or from a browser the owner signs in from) is marked so
|
||||
// a goal it leads to is kept as a test, never counted (2026-10-26). Only for owners who track goals; never blocks the click.
|
||||
async function markOwnClick(id, owner, req) {
|
||||
try {
|
||||
if (!owner || !convtrack.goalsOf(owner).length) return;
|
||||
let email = ''; if (/(?:^|;\s*)iap\.sid=/.test(req.headers.cookie || '')) { const s = await auth.fromRequest(req); email = (s && s.email) || ''; }
|
||||
convtrack.markSelfClick(id, owner, req, email);
|
||||
} catch (e) { console.error('own click mark', e.message); }
|
||||
}
|
||||
async function adClickTarget(campOrId, url, req, extra) {
|
||||
try {
|
||||
const camp = typeof campOrId === 'object' ? campOrId : await ads.campaignById(campOrId); if (!camp) return { url };
|
||||
@@ -1234,6 +1244,7 @@ const server = http.createServer(async (req, res) => {
|
||||
let rm = /^\/r\/([a-z0-9]{4,12})$/i.exec(p);
|
||||
if (rm && (req.method === 'GET' || req.method === 'HEAD')) {
|
||||
const hit = await rotator.resolve(rm[1], req);
|
||||
if (hit && hit.lsid) await markOwnClick(hit.lsid, hit.rotation && hit.rotation.owner, req);
|
||||
if (hit && hit.url) { res.writeHead(302, { Location: hit.url, 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer-when-downgrade' }); return res.end(); }
|
||||
res.writeHead(404, { 'Content-Type': 'text/html; charset=utf-8' }); return res.end(linkSitePage(reqHost(req), 'gone'));
|
||||
}
|
||||
@@ -1258,6 +1269,7 @@ const server = http.createServer(async (req, res) => {
|
||||
res.writeHead(200, Object.assign({}, fresh, { 'Content-Type': 'application/javascript; charset=utf-8' })); return res.end(req.method === 'HEAD' ? '' : js);
|
||||
}
|
||||
const ck = await bannerspin.click(bm[2], req, host);
|
||||
if (ck && ck.lsid) await markOwnClick(ck.lsid, ck.owner, req);
|
||||
if (ck && ck.url) { res.writeHead(302, { Location: ck.url, 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer-when-downgrade', 'X-Robots-Tag': 'noindex' }); return res.end(); }
|
||||
res.writeHead(404, { 'Content-Type': 'text/html; charset=utf-8' }); return res.end(linkSitePage(host, 'gone'));
|
||||
} }
|
||||
@@ -1284,7 +1296,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (id) h['Set-Cookie'] = clickCookie(id); h['X-LS-Result'] = id ? 'stored' : 'ignored';
|
||||
} else if (convtrack.isPx(px)) {
|
||||
const r = convtrack.record({ px, goal: u.searchParams.get('goal'), value: u.searchParams.get('value'), c: String(u.searchParams.get('c') || u.searchParams.get('lsclk') || u.searchParams.get('lsid') || u.searchParams.get('clickid') || refClickId(req) || ''), m: u.searchParams.get('m'), test: u.searchParams.get('test') === '1' }, req, parseCookies(req));
|
||||
h['X-LS-Result'] = r.result + (r.method ? ';' + r.method : '');
|
||||
h['X-LS-Result'] = r.result + (r.method ? ';' + r.method : '') + (r.conv && r.conv.self ? ';self' : ''); // ;self = the owner's own click, kept as a test
|
||||
if (r.result === 'counted' && !r.conv.self) postbacks.fire(r.conv.owner, r.conv.goal, Object.assign(convtrack.postbackCtx(r), { goal: true })).catch(e => console.error('goal postback', e.message));
|
||||
} else h['X-LS-Result'] = 'unknown';
|
||||
} catch (e) { console.error('conversion pixel', e.message); h['X-LS-Result'] = 'error'; }
|
||||
@@ -2760,7 +2772,8 @@ const server = http.createServer(async (req, res) => {
|
||||
// goals live on their LinkSpin account (same email): summary for the Campaigns rows, create / update / remove / test.
|
||||
if (p === '/api/partner/clicks' && req.method === 'POST') {
|
||||
const sg = await readPartnerSigned(req, 2e6); if (!sg.body) return json(res, sg.status, { error: sg.error });
|
||||
return json(res, 200, { ok: true, n: convtrack.importClicks(sg.body.clicks) });
|
||||
const owners = convtrack.importOwners(sg.body.owners); // InstantAdPay members' own soft keys first, so their own clicks import as tests
|
||||
return json(res, 200, { ok: true, n: convtrack.importClicks(sg.body.clicks), owners });
|
||||
}
|
||||
// -- the Engine Room, partner side: LinkSpin's facts for one member (InstantAdPay builds its panel from them)
|
||||
if (p === '/api/partner/engine' && req.method === 'POST') {
|
||||
|
||||
Reference in New Issue
Block a user