From 06f0a8745293adf420ef875f6ff3ade8afff39dd Mon Sep 17 00:00:00 2001 From: martbost Date: Mon, 26 Oct 2026 06:31:18 -0500 Subject: [PATCH] Conversion tracking fixes (Marty approved 2026-10-26): real test pixel, own-click count, own-browser clicks as tests, cost per goal (30 days) 1. Own clicks: auth.onSeen notes the soft key of every InstantAdPay session (lsconv.noteSession, once per 6 h per email + soft key) and the click push carries them as owners [{owner, sk, ts}] (requeued on a failed push), so LinkSpin keeps members' own clicks on their ads, spin links and Banner Spins as tests. /api/ads/click flags a click self for conversions when signed in as the owner OR from a browser the owner signs in from; whether the click is counted and billed is unchanged (still the signed-in check). Linked positions share the owner's email. 2. Send a test conversion now loads the member's real LinkSpin pixel in test mode from the browser (cv.gif?px=..&test=1, reads X-LS-Result: test, the same request LinkSpin's button makes) and falls back to the signed partner call (op test) when the browser cannot load it; CSP connect-src adds https://linkspin.app. The card shows "N from your own clicks, kept as tests and left out" (selfTests from LinkSpin's summary). 4. Cost per goal (30 days): /api/my/conversions returns spend30 = each campaign's spend over the same 30 days from credit_log (ads.spendSince: delivery, login, buy, refund rows by Central day, ref = campaign id). Campaign lines read "Goals and cost per goal (30 days)"; a campaign started inside the window with no log rows uses its spend since start (labelled in the tooltip); an older campaign with no spend on record shows no cost rather than a lifetime figure. Copy: Conversion tracking card note, /conversion-tracking (test button, own clicks, cost per goal (30 days) row). Chatbot CANNED + FACTS, KNOWLEDGE_DATE 2026-10-26. my.js ?v=20261026cv. QA: convpixel all passed (new: owners pushed without raw IP, own-browser click self=1 and stranger 0, no re-push within 6 h, spend30 = 200 of the window with the 40-day-old row and another member left out, 50/200 credits each vs lifetime 75, no-log old campaign shows no cost, new campaign uses spend since start, own-click count on the card, test button loads cv.gif?px&test=1 in the browser (routed locally) and falls back to op test); fuel all pass (engine.js / engine-room.js / kit.js untouched, byte-identical with LinkSpin); member walk 0 bugs; public 0 bugs (known /shorts ellipsis warning). Co-Authored-By: Claude Opus 5.5 --- ads.js | Bin 162744 -> 164067 bytes auth.js | 9 ++++- chatbot.js | 6 +-- lsconv.js | 34 +++++++++++++--- public/assets/my.js | 29 ++++++++++---- public/conversion-tracking.html | 14 +++---- public/my.html | 4 +- qa/convpixel.test.mjs | 66 +++++++++++++++++++++++++++++--- server.js | 13 +++++-- 9 files changed, 138 insertions(+), 37 deletions(-) diff --git a/ads.js b/ads.js index 0bbaaa91f5cdbd41a35e19239955f122597bfac3..1cf161b7188d19123d98f492606b48ee976a6c3a 100644 GIT binary patch delta 1094 zcmZvc&rcIU6vtDHsEr&DBLNRQOr*PJcd3|gfK-B%7$Po&%E2^5rn|H4q`NzHca~bA zsXzVz6Zg<~<4^Dg2PDeTlNS#jiC53+(Kp+oMNJRw&c64)-_Q3=y8q+C*XQZCV@IvY zNw5NHGZ6wMRt2~N1U%}MXpjlPB3_NKvL8ZNqrQNU`4*K0+`~r=oPc{EDzrNTh$Yw- z6Af^A8I-B))UX3^L1h;;&{};u{b}f z>4<`WR)qv*8qOkPK%EF*asQMkf_OBdHZc;pLeL#Y8hDt|)3`LLNpwh0b#U2OA> zM0t&hD8N*=ThfqX+jee@_P|bXQBc=?IUmf81!^g|8-;q$tps64VmT}oz+8C%=KAt7++AB)UxhmlM-tATC~cDMsWNa!rW#`E8XW9x9}^?rXGA6{#Jy4W|2E~O4k zOaPOEU_1wYe)!VJlC+CtKqSWtS5ot!4>pyPa8tsqIp01gj8vG@%c ze--eSU}uM``ZtT5S=~_M Conversion tracking { id: 'conversion-tracking', title: 'Conversion tracking (goal pixel)', q: ['How do I track conversions?', 'Can I see which ad brought a sign-up or sale?', 'Where do I put the goal pixel?', 'What is the landing tag?', 'How do I set up conversion tracking on WordPress?'], tags: ['conversion tracking', 'goal pixel', 'landing tag', 'cost per goal', 'aweber', 'getresponse', 'wordpress', 'setup guide'], re: /(conver(sion|t)s?.{0,20}(track|pixel|goal)|track(ing)?.{0,30}(conversions?|sign.?ups?|sales|subscribers|leads)|goal pixel|landing tag|tracking pixel|cost per (goal|lead|sale|sign.?up|conversion)|thank.?you page|lsclk)/i, - a: 'Conversion tracking shows which of your ads bring subscribers and sales, not just clicks. It lives in your dashboard under Campaigns > Conversion tracking (https://instantadpay.com/my#campaigns). Three steps: 1) add a goal, like subscriber or sale (a default value is optional); 2) put the landing tag on the page your ad points to; 3) put the goal pixel on your thank-you page. Every click on your ad carries a click id (lsclk=...), and LinkSpin, our sister site, matches each goal to the click: first by the click id still in the address, then the id the landing tag stored, then LinkSpin\'s cookie, and last a 24-hour match on the same connection and browser (the panel says how sure each kind is). Each goal counts once per click, only within 30 days of a real click on your ad, and each campaign shows its goals and cost per goal in credits. Using Aweber or GetResponse? Set the form\'s thank-you (success) page to a page on YOUR site that carries the goal pixel (Aweber: Thank You Page: custom page; GetResponse: Thank-you page: custom URL). If you cannot change it, the pixel can still count through the cookie or the 24-hour match, just less surely. The Send a test conversion button checks your pixel; tests and clicks on your own ads never count in your numbers. The step-by-step guide, with copy-paste examples for plain HTML, WordPress, page builders and autoresponder thank-you pages, how to read the report and a troubleshooting checklist: https://instantadpay.com/conversion-tracking' }, + a: 'Conversion tracking shows which of your ads bring subscribers and sales, not just clicks. It lives in your dashboard under Campaigns > Conversion tracking (https://instantadpay.com/my#campaigns). Three steps: 1) add a goal, like subscriber or sale (a default value is optional); 2) put the landing tag on the page your ad points to; 3) put the goal pixel on your thank-you page. Every click on your ad carries a click id (lsclk=...), and LinkSpin, our sister site, matches each goal to the click: first by the click id still in the address, then the id the landing tag stored, then LinkSpin\'s cookie, and last a 24-hour match on the same connection and browser (the panel says how sure each kind is). Each goal counts once per click, only within 30 days of a real click on your ad, and each campaign shows its goals and its cost per goal (30 days) in credits: the credits that campaign spent in the same 30 days, divided by its goals. Using Aweber or GetResponse? Set the form\'s thank-you (success) page to a page on YOUR site that carries the goal pixel (Aweber: Thank You Page: custom page; GetResponse: Thank-you page: custom URL). If you cannot change it, the pixel can still count through the cookie or the 24-hour match, just less surely. The Send a test conversion button fires your real pixel in test mode (Last test updates); to check your real thank-you page, add &test=1 to its pixel and open it once. Tests and your own clicks (on your ads, and on your LinkSpin spin links and Banner Spins) never count in your numbers; the card says how many of your own clicks were kept as tests. The step-by-step guide, with copy-paste examples for plain HTML, WordPress, page builders and autoresponder thank-you pages, how to read the report and a troubleshooting checklist: https://instantadpay.com/conversion-tracking' }, // 2026-10-23 (Marty: "they need to pay for the slot now to get a place in line"): 6 member slots, then a prepaid line { id: 'login-ads', title: 'Login ads: slots and the paid line', q: ['How do login ads work?', 'All login ad slots are taken, what now?', 'Can I reserve a login ad slot?', 'Can I cancel my login ad reservation?'], tags: ['login ad', 'login slot', 'reserve', 'queue', 'line', 'refund'], re: /(log ?in.?ads?|sign.?in ads?|log ?in (ad )?(slots?|sponsor)|(reserve|reservation|queue|place in line|waiting list).{0,40}log ?in|log ?in.{0,40}(slots?|reserve|reservation|queue|place in line|waiting list)|reserve (a |the )?(next )?slot)/i, @@ -227,7 +227,7 @@ ${passTiersFact()}${refuelFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagen - HELP DESK (LIVE 2026-10-16): members open Help in the dashboard (/my#help) to send Marty a support ticket (pick a category, a subject, the message, up to 2 screenshots), see each ticket's status (Open, Waiting on you, Closed) and read and answer his replies; a badge shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at https://instantadpay.com/support (name, email, category, subject, message) and gets an email with the ticket number (like IAP-1042) and a private link to view and reply, no sign-in needed. support@instantadpay.com also reaches Marty. Replying to a closed ticket opens it again. In this chat, "Send this to support" turns the conversation into a ticket. Only Marty answers, so replies are not instant; never promise a response time. - PRESENTATION (2026-10-15): instantadpay.com/presentation is a public page (no sign-in) with the narrated InstantAdPay presentation, about six minutes, Marty's voice, captions in 6 languages (English, Italiano, Français, Español, Deutsch, Português) chosen with pills under the player. Sixteen parts: the platform, ad reach, the nine games that pay POL, the $20 split ($10 / $4 / $2 / $4 platform, same transaction), three rules, packages, the 2-then-5 unlock, pass-up, wide versus narrow ($800 vs $36, an illustration), Qualified Start, the Pipeline, LinkSpin (pre-launch Nov 1), one wallet across the network, the first week, and 'the target is five'. Share link: Members > Promo tools > 'Share the presentation' copies instantadpay.com/presentation?ref=; ?ref sets the same 30-day sponsor cookie as the invite link, the page shows 'Shared with you by @name' with avatar and a Join button to /join/. It is in the site menu as 'Presentation'. BUILD WIDE VIDEO: first card in Promo tools > Videos ('Build wide: watch the payments flow'), matched link ?v=wide. - WIRED WEDNESDAY: every Wednesday, Central time (midnight to midnight), any ad package of $20 or more (Activation and up; no $10 pack exists) earns +25% bonus credits wired into the buyer's balance the moment the purchase settles, purchased-grade (usable on every format incl. login ads), credit log label "Wired Wednesday". First one: Wednesday 2026-09-30. Page: instantadpay.com/wednesday. Credits buy ad delivery, never money. -- CONVERSION TRACKING (LIVE 2026-10-23): Campaigns > Conversion tracking in /my#campaigns. Every click on a member's ad (through /api/ads/click) gets a click id added to the target address as lsclk=; the advertiser adds a goal (name like subscriber or sale, optional default value), puts the LinkSpin landing tag (t.js) on the page the ad points to and the goal pixel (cv.gif image, or the cv.js script) on the thank-you page. LinkSpin (sister site, same email) counts the goals; matching order: click id in the address (url, surest), the id the landing tag stored (stored), LinkSpin's cookie (cookie), a 24-hour match on hashed IP plus browser (soft, least sure). Each goal counts once per click, only within 30 days of a real click, only for the pixel owner's own ads; the advertiser's own clicks and the Send a test conversion button count as tests, never in the numbers. Each campaign row shows goals and cost per goal in credits (campaign credits spent divided by goals; never quote it in dollars). Autoresponder tip: set the Aweber or GetResponse thank-you (success) page to a page on the member's own site carrying the goal pixel (Aweber: Thank You Page: custom page; GetResponse: Thank-you page: custom URL); if they cannot, the cookie or the 24-hour match can still count it, less surely. Privacy: the click id is random and nothing personal is sent. SETUP GUIDE (public, 2026-10-24): https://instantadpay.com/conversion-tracking (LinkSpin's copy: https://linkspin.app/conversion-tracking): why track, the flow, the 4 steps (goal, landing tag, goal pixel, test), copy-paste examples (plain HTML, WordPress footer plugin + Custom HTML block, page builders, Aweber/GetResponse custom thank-you page), the page check (add &test=1 to the pixel address, open the thank-you page, Last test updates, then remove it), what to do without code on the thank-you page, how to read the report and a troubleshooting checklist (same domain for landing and thank-you page, goal pixel only on the thank-you page, the script version is surest). Send members there for any setup question. +- CONVERSION TRACKING (LIVE 2026-10-23): Campaigns > Conversion tracking in /my#campaigns. Every click on a member's ad (through /api/ads/click) gets a click id added to the target address as lsclk=; the advertiser adds a goal (name like subscriber or sale, optional default value), puts the LinkSpin landing tag (t.js) on the page the ad points to and the goal pixel (cv.gif image, or the cv.js script) on the thank-you page. LinkSpin (sister site, same email) counts the goals; matching order: click id in the address (url, surest), the id the landing tag stored (stored), LinkSpin's cookie (cookie), a 24-hour match on hashed IP plus browser (soft, least sure). Each goal counts once per click, only within 30 days of a real click, only for the pixel owner's own ads; the advertiser's own clicks (signed in, or from a browser they sign in from; their linked positions share their email so count as them too) and the Send a test conversion button count as tests, never in the numbers; the card shows 'N from your own clicks, kept as tests'. SEND A TEST CONVERSION (2026-10-26) loads the member's real LinkSpin pixel in test mode from their browser (falls back to the signed partner call if the browser blocks it), so Last test updates. Each campaign row shows goals and COST PER GOAL (30 DAYS) in credits (2026-10-26: the credits the campaign spent in the last 30 days, from the credit activity log, divided by its goals in the same 30 days; a campaign started inside the window uses its spend since start; never quote it in dollars). Autoresponder tip: set the Aweber or GetResponse thank-you (success) page to a page on the member's own site carrying the goal pixel (Aweber: Thank You Page: custom page; GetResponse: Thank-you page: custom URL); if they cannot, the cookie or the 24-hour match can still count it, less surely. Privacy: the click id is random and nothing personal is sent. SETUP GUIDE (public, 2026-10-24): https://instantadpay.com/conversion-tracking (LinkSpin's copy: https://linkspin.app/conversion-tracking): why track, the flow, the 4 steps (goal, landing tag, goal pixel, test), copy-paste examples (plain HTML, WordPress footer plugin + Custom HTML block, page builders, Aweber/GetResponse custom thank-you page), the page check (add &test=1 to the pixel address, open the thank-you page, Last test updates, then remove it), what to do without code on the thank-you page, how to read the report and a troubleshooting checklist (same domain for landing and thank-you page, goal pixel only on the thank-you page, the script version is surest). Send members there for any setup question. - FIVE DOLLAR FRIDAY: every Friday, Central time, any ad package of $5 or more earns +20% bonus credits, credited the moment the purchase settles (credit log shows the label). First one: Friday 2026-09-25. Since 2026-10-23 the same $5+ Friday package also gives a FREE 7-day Game Pass automatically (once per member per Friday; not a second week when that package itself fulfils a pass order; the Game Pass badge posts the first time). Five Fridays in a row = the Five Fridays badge. The point: the whole network buys on the same day, every pack pays its sponsor line in the same transaction, so every line gets paid at once. No income promises. - SESSIONS LAST 4 HOURS. Sign-ins expire after 4 hours and the member signs in again with a fresh 6-digit code. This is intentional and we say so plainly: it keeps resources optimised, and the login sponsor ad shown on the way back in is part of what pays for the free side. Nothing is lost on expiry - credits, line and account are untouched. Never describe it as a bug, an error, or something to report. - Free to join with email only (6-digit code sign-in, no passwords). Wallet appears only at purchase or payout activation. Every new member gets a small welcome batch of ad credits — unlocked by the WELCOME TOUR on first sign-in: they visit their upline's line-banner sites (up to 3, 10 seconds each — the same 3 levels the contract pays), then claim the credits. Members with no upline banners get the credits instantly. diff --git a/lsconv.js b/lsconv.js index 603df6b..3c11ff2 100644 --- a/lsconv.js +++ b/lsconv.js @@ -8,6 +8,8 @@ // LinkSpin upserts by id, so two app copies pushing the same rows during a deploy is harmless. // conv(email,..) the member's goals and summary through POST /api/partner/conv (op summary/create/update/remove/test), // summary cached 60 s per email. +// owners (2026-10-26) the soft keys members sign in from ride on the click push, so LinkSpin keeps a member's own +// clicks (ads here, spin links and Banner Spins there) as tests, never counted // No LS_SYNC_SECRET (or shorter than 32 chars): clicks still get ids and rows, nothing is sent. // The raw IP is never stored: only the soft key 's:' + sha256(ip + '|' + ua) first 20 hex, same on both sites. 'use strict'; @@ -73,6 +75,24 @@ function withClickId(target, id) { return base + sep + 'lsclk=' + encodeURIComponent(id) + hash; } +// ---- own-click tests (Marty approved 2026-10-26) ---- +// A member's own click is a test on LinkSpin, on every click type. LinkSpin knows the soft keys its members sign in from; +// InstantAdPay members may never sign in there, so the soft keys of their InstantAdPay sessions ride along with the click +// push as owners: [{ owner, sk, ts }] (no raw IP, same hash as the click rows). Queued at most once per 6 h per +// email + soft key; a failed push puts them back. Also checked here so an own click is flagged self=1 at the source. +const OWN_MS = 31 * 86400e3, ownSeen = new Map(); let ownQueue = new Map(); +function noteSession(email, ip, ua) { + const e = String(email || '').trim().toLowerCase(); if (!e || e.length > 190) return false; + const sk = softKey(ip, ua); const k = e + '|' + sk; const now = Date.now(); + if (now - (ownSeen.get(k) || 0) < 6 * 3600e3) return false; + ownSeen.set(k, now); if (ownSeen.size > 50000) ownSeen.delete(ownSeen.keys().next().value); + if (on()) { ownQueue.set(k, { owner: e, sk, ts: now }); if (ownQueue.size > 5000) ownQueue.delete(ownQueue.keys().next().value); } + return true; +} +function isOwnerSk(owner, sk) { const t = ownSeen.get(String(owner || '').toLowerCase() + '|' + sk); return !!(t && Date.now() - t <= OWN_MS); } +function takeOwners() { const out = [...ownQueue.values()].slice(0, 2000); for (const o of out) ownQueue.delete(o.owner + '|' + o.sk); return out; } +function requeueOwners(list) { for (const o of list || []) if (!ownQueue.has(o.owner + '|' + o.sk)) ownQueue.set(o.owner + '|' + o.sk, o); } + // ---- storage ---- function jload() { if (jstate) return jstate; try { jstate = JSON.parse(fs.readFileSync(JFILE(), 'utf8')); if (!Array.isArray(jstate.rows)) throw 0; } catch (e) { jstate = { rows: [] }; } return jstate; } function jsave() { if (saveT) return; saveT = setTimeout(() => { saveT = null; try { fs.writeFileSync(JFILE(), JSON.stringify(jload())); } catch (e) {} }, 500); } @@ -121,11 +141,13 @@ async function flush() { if (!on() || flushing || Date.now() < nextAt) return { skipped: true }; flushing = true; let sent = 0; try { - for (let round = 0; round < 20; round++) { // drain a backlog, 500 at a time - const rows = await unpushed(500); if (!rows.length) break; - const res = await signedPost('/api/partner/clicks', { clicks: rows }, 20000); - if (!res || res.ok !== true) throw new Error('linkspin answered without ok'); - await markPushed(rows.map(r => r.id)); sent += rows.length; stats.pushed += rows.length; stats.lastAt = Date.now(); + for (let round = 0; round < 20; round++) { // drain a backlog, 500 at a time; owners (own soft keys) ride on the first request + const rows = await unpushed(500); const owners = round === 0 ? takeOwners() : []; + if (!rows.length && !owners.length) break; + let res; try { res = await signedPost('/api/partner/clicks', { clicks: rows, owners }, 20000); } catch (e) { requeueOwners(owners); throw e; } + if (!res || res.ok !== true) { requeueOwners(owners); throw new Error('linkspin answered without ok'); } + if (rows.length) { await markPushed(rows.map(r => r.id)); sent += rows.length; stats.pushed += rows.length; stats.lastAt = Date.now(); } + if (owners.length) stats.owners = (stats.owners || 0) + owners.length; if (rows.length < 500) break; } fails = 0; nextAt = 0; return { sent }; @@ -151,4 +173,4 @@ async function goalOp(email, op, fields) { cache.delete(e); return out; } function adminView() { return { on: on(), url: URL_(), pushed: stats.pushed, lastAt: stats.lastAt, errors: stats.errors, lastError: stats.lastError, fails, nextAt: nextAt || null }; } -module.exports = { init, record, flush, summary, goalOp, withClickId, softKey, placementOf, deviceOf, newId, adminView, on }; +module.exports = { init, record, flush, summary, goalOp, withClickId, softKey, placementOf, deviceOf, newId, adminView, on, noteSession, isOwnerSk }; diff --git a/public/assets/my.js b/public/assets/my.js index 56fdd09..737a74f 100644 --- a/public/assets/my.js +++ b/public/assets/my.js @@ -1104,13 +1104,19 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str document.querySelectorAll('[data-convcamp]').forEach(el => { el.hidden = true; el.innerHTML = ''; }); if (!d || !d.ok || !(d.goals || []).length) return; const by = d.byCampaign || {}; + // cost per goal (30 days), 2026-10-26: goals are the last 30 days, so the spend is too. spend30 = credits each campaign + // spent in those days (credit activity log). A campaign started inside the window with no log rows uses its spend + // since it started (all of it is inside the window); otherwise no cost is shown rather than a lifetime figure. + const sp30 = d.spend30 || null, since = Number(d.spendSince) || (Date.now() - 30 * 86400000); document.querySelectorAll('[data-convcamp]').forEach(el => { const id = el.dataset.convcamp; const b = by[id]; const c = convCamps.find(x => String(x.id) === String(id)); if (!c) return; - const spent = Number(c.spent || 0); + let spent = null, basis = ''; + if (sp30 && sp30[id] != null) { spent = Number(sp30[id]) || 0; basis = 'the credits it spent in the same 30 days'; } + else if (Number(c.created) >= since) { spent = Number(c.spent || 0); basis = 'the credits it spent since it started on ' + new Date(Number(c.created)).toLocaleDateString([], { month: 'short', day: 'numeric' }) + ', inside the 30 days'; } const parts = d.goals.map(g => { const n = Number(b && b.conv && b.conv[g.px]) || 0; - return '' + esc(g.name) + ' ' + n.toLocaleString() + (n > 0 ? ' (' + convFmt(spent / n) + ' credits each)' : '') + ''; }); - el.innerHTML = '\u{1F3AF} ' + parts.join(' · ') + (b && b.clicks ? ' · ' + Number(b.clicks).toLocaleString() + ' tracked clicks' : ''); - el.title = 'Goals counted for this campaign in the last 30 days. Cost per goal = the credits this campaign has spent, divided by its goals.'; + return '' + esc(g.name) + ' ' + n.toLocaleString() + (n > 0 && spent != null ? ' (' + convFmt(spent / n) + ' credits each)' : '') + ''; }); + el.innerHTML = '\u{1F3AF} Goals and cost per goal (30 days): ' + parts.join(' · ') + (spent == null ? ' · no spend on record for these 30 days, so no cost per goal' : '') + (b && b.clicks ? ' · ' + Number(b.clicks).toLocaleString() + ' tracked clicks' : ''); + el.title = 'Goals counted for this campaign in the last 30 days. Cost per goal (30 days) = ' + (spent != null ? basis : 'the credits it spent in the same 30 days') + ', divided by those goals.'; el.hidden = false; }); } @@ -1125,7 +1131,9 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str add.hidden = false; const goals = d.goals || []; const m = d.methods || {}; const mt = ['url', 'stored', 'cookie', 'soft'].reduce((s, k) => s + (Number(m[k]) || 0), 0); - st.textContent = goals.length ? (mt ? 'How your conversions were matched (30 days): ' + ['url', 'stored', 'cookie', 'soft'].map(k => k + ' ' + Number(m[k] || 0).toLocaleString()).join(', ') + '.' : 'No conversions counted yet in the last 30 days.') : 'No goals yet. Add your first one below.'; + const selfN = Number(d.selfTests) || 0; // own clicks (ads here, spin links and Banner Spins on LinkSpin), kept as tests + st.textContent = goals.length ? (mt ? 'How your conversions were matched (30 days): ' + ['url', 'stored', 'cookie', 'soft'].map(k => k + ' ' + Number(m[k] || 0).toLocaleString()).join(', ') + '.' : 'No conversions counted yet in the last 30 days.') + + (selfN ? ' ' + selfN.toLocaleString() + ' from your own clicks, kept as tests and left out.' : '') : 'No goals yet. Add your first one below.'; if (!goals.length) { list.innerHTML = ''; snips.innerHTML = ''; return; } if (!convSel || !goals.some(g => g.px === convSel)) convSel = goals[0].px; const when = ts => ts ? new Date(ts).toLocaleString([], { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : 'never'; @@ -1145,10 +1153,15 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str + '

Use it where your page allows scripts. It also sends the click id the landing tag stored, which makes the count surer.

' + convBox('convJs', 'Goal pixel, JS version', sn.js) + ''; list.querySelectorAll('[data-convpick]').forEach(b => b.addEventListener('click', () => { convSel = b.dataset.convpick; loadConv(); })); + // Send a test conversion (2026-10-26): loads the member's REAL pixel in test mode from this browser, the same request a + // thank-you page makes (LinkSpin answers X-LS-Result: test). If the browser blocks it, the signed partner call records the test. list.querySelectorAll('[data-convtest]').forEach(b => b.addEventListener('click', async () => { - b.disabled = true; - try { await api('/api/my/conversions/test', { px: b.dataset.convtest }); IAP.status('Test conversion sent. It shows under Last test and never counts in your numbers.', 'ok'); await loadConv(true); } - catch (e) { IAP.status(e.message, 'bad'); b.disabled = false; } + b.disabled = true; const px = b.dataset.convtest; let via = ''; + const base = 'https://' + String(d.host || 'linkspin.app').replace(/^https?:\/\//, '').replace(/\/+$/, ''); + try { const r = await fetch(base + '/cv.gif?px=' + encodeURIComponent(px) + '&test=1&r=' + Date.now(), { cache: 'no-store', mode: 'cors', credentials: 'omit' }); if (r.ok && /^test/.test(r.headers.get('X-LS-Result') || '')) via = 'pixel'; } catch (e) {} + if (!via) { try { await api('/api/my/conversions/test', { px }); via = 'relay'; } catch (e) { IAP.status(e.message, 'bad'); b.disabled = false; return; } } + IAP.status(via === 'pixel' ? 'Test conversion received by your real pixel. It shows under Last test and never counts in your numbers.' : 'Test conversion recorded through InstantAdPay (this browser did not load the pixel itself). It shows under Last test and never counts in your numbers.', 'ok'); + await loadConv(true); })); list.querySelectorAll('[data-convdel]').forEach(b => b.addEventListener('click', async () => { const yes = await IAP.confirmBox('Remove the goal "' + b.dataset.convname + '"? Its pixel stops counting. Pages that still carry it will simply be ignored.', { title: 'Remove goal', ok: 'Remove', cancel: 'Keep it' }); diff --git a/public/conversion-tracking.html b/public/conversion-tracking.html index 06d53c1..6ed8426 100644 --- a/public/conversion-tracking.html +++ b/public/conversion-tracking.html @@ -104,7 +104,7 @@

Clicks are not sign-ups

One ad can get lots of clicks from people who never sign up. Another gets fewer clicks and brings you subscribers. Without tracking, both look the same, or the wrong one looks better.

Find the winner

Every goal is counted against the ad that sent the visitor. You see which campaign, which landing page and which traffic source produced the sign-up or the sale.

-

A cost per goal, in credits

Each campaign shows its goals and what each one cost: the credits the campaign has spent, divided by its goals. Lower is better. Compare two ads on the same offer and you know which to keep.

+

A cost per goal, in credits

Each campaign shows its goals and what each one cost: the credits the campaign spent in the last 30 days, divided by its goals in those 30 days. Lower is better. Compare two ads on the same offer and you know which to keep.

Put next month's fuel behind it

This is the "your numbers get useful" part of Fuel Your Offers. Run your ads all month, let the goals come in, then put next month's refuel behind the ad and the page that convert, instead of guessing.

@@ -144,11 +144,11 @@
  • Send a test conversion

    -

    Press Send a test conversion on your goal. It shows under Last test and never counts in your numbers. That proves your pixel id is live.

    -

    To check the pixel on your real thank-you page, add &test=1 to the end of the pixel address, open your thank-you page once, and reload your dashboard a minute later: Last test updates. Then take &test=1 back out. Last, click one of your own ads and look at the address bar on your landing page: you should see lsclk= in it.

    +

    Press Send a test conversion on your goal. It loads your real pixel in test mode, the same request your thank-you page makes. It shows under Last test and never counts in your numbers. That proves your pixel id is live.

    +

    To check the pixel on your real thank-you page, add &test=1 to the end of the pixel address, open your thank-you page once, and reload your dashboard a minute later: Last test updates. Then take &test=1 back out. Last, click one of your own ads and look at the address bar on your landing page: you should see lsclk= in it. That click is yours, so anything you finish after it is kept as a test, never counted.

  • -

    Your own clicks on your own ads are kept as tests. They never show in your numbers, so a full run-through of your own funnel will not inflate anything.

    +

    Your own clicks are kept as tests: on your ads here, and on your spin links and Banner Spins on LinkSpin, whether you are signed in on that browser or it is one you sign in from. They never show in your numbers, so a full run-through of your own funnel will not inflate anything. The card says how many of your own clicks were kept as tests.

    Copy and paste

    Where the code goes, by platform

    @@ -216,7 +216,7 @@ You seeWhat it means Conversions (30 days)Goals counted for this goal in the last 30 days, tests and your own clicks left out. - Cost per goal, in creditsThe credits the campaign has spent so far, divided by its goals in the last 30 days. Spend is the campaign's total, so on a campaign that has run longer than 30 days this figure reads high. It is in ad credits, never dollars. + Cost per goal (30 days), in creditsThe credits the campaign spent in the last 30 days, divided by its goals in the same 30 days, so an older campaign reads the same way as a new one. Spend comes from your credit activity (Campaigns, Credit activity). It is in ad credits, never dollars. url (LinkSpin: Address)Surest. The thank-you page's own address still carried the click id. stored (LinkSpin: Kept)Very sure. The landing tag kept the click id on your site and the goal pixel read it back. cookie (LinkSpin: Cookie)Fairly sure. Matched through LinkSpin's own cookie in the visitor's browser. Some browsers block it. @@ -226,7 +226,7 @@
    -

    The counting rules

    Each goal counts once per click, so one person signing up twice from one click is one goal. A goal counts only within 30 days of a real click, and only for clicks on your own ads. Your own clicks on your ads are kept as tests.

    +

    The counting rules

    Each goal counts once per click, so one person signing up twice from one click is one goal. A goal counts only within 30 days of a real click, and only for clicks on your own ads. Your own clicks are kept as tests, never counted.

    More detail on LinkSpin

    Sign in to LinkSpin with the same email and open Conversions in the Control Room for the full breakdown: by ad campaign (both sites), by destination page and by traffic source, a 7, 30 or 90 day range, and a CSV download.

    @@ -240,7 +240,7 @@
  • Same domain for both pages? The landing tag keeps the id on one domain. If the landing page is on www.yoursite.com and the thank-you page on yoursite.com (or another site), the script pixel cannot read it and only the cookie or 24-hour match is left.
  • Goal pixel only on the thank-you page? Not in a site-wide footer, not on the landing page.
  • Scripts stripped? Some builders and hosted blogs remove scripts. Use the image version of the goal pixel there.
  • -
  • Testing with your own clicks? Your own clicks on your ads are kept as tests and never show in the counts. Use the test steps above instead.
  • +
  • Testing with your own clicks? Your own clicks on your ads (and on your LinkSpin spin links and Banner Spins) are kept as tests and never show in the counts. Use Send a test conversion and the &test=1 check above instead.
  • Older than 30 days, or the same click twice? A sign-up more than 30 days after the click does not count, and each click counts once per goal.
  • diff --git a/public/my.html b/public/my.html index 90ac978..53a29b3 100644 --- a/public/my.html +++ b/public/my.html @@ -646,7 +646,7 @@
  • LinkSpin cookie (cookie): fairly sure. Matched through LinkSpin's own cookie in the visitor's browser. Some browsers block it.
  • 24-hour match (soft): least sure. Same connection and browser within 24 hours of a click. A good guess, not a proof.
  • -

    Each goal counts once per click, only within 30 days of a real click on one of your ads. Your own clicks on your ads and the test button count as tests, never in your numbers.

    +

    Each goal counts once per click, only within 30 days of a real click on one of your ads. Your own clicks (on your ads here, and on your LinkSpin spin links and Banner Spins) and the test button count as tests, never in your numbers. Send a test conversion loads your real pixel in test mode. Cost per goal (30 days) = the credits a campaign spent in the same 30 days, divided by its goals.

    @@ -1223,7 +1223,7 @@ - + diff --git a/qa/convpixel.test.mjs b/qa/convpixel.test.mjs index bfabc4b..57e570d 100644 --- a/qa/convpixel.test.mjs +++ b/qa/convpixel.test.mjs @@ -7,7 +7,10 @@ // gets it, an existing lsclk is never replaced, an unparsable target goes out unchanged), the click rows pushed with a valid // signature and the contract fields, the owner's own click flagged self=1 and not counted, the proxies, the Campaigns pane // showing goals and cost per goal (300 credits / 4 = 75), LinkSpin down: pane still loads, panel says so, rows kept and -// pushed once it is back. Exit code 1 on any failure. +// pushed once it is back. 2026-10-26: own soft keys pushed as owners and an own-browser click flagged self (billing +// unchanged), Send a test conversion loads the real pixel in test mode (routed in the browser, nothing leaves the machine) +// with the partner call as fallback, the own-click test count on the card, cost per goal (30 days) from the credit log. +// Exit code 1 on any failure. import http from 'node:http'; import crypto from 'node:crypto'; import fs from 'node:fs'; @@ -38,12 +41,17 @@ const camp = (id, owner, name, targetUrl, spent) => ({ id, owner, memberId: 0, t budget: 1000, spent, accrued: 0, imps: 50, clicks: 0, batchImps: 0, width: 468, height: 60, status: 'paused', created: now - 86400000 }); const T1 = 'https://adv.example/landing?utm_source=iap&x=a%2Cb&q=hello+world#top'; const CAMPS = [camp(1, A1, 'QA landing', T1, 300), camp(2, A1, 'QA spin link', 'https://linkspin.app/r/abc12', 120), - camp(3, A1, 'QA has lsclk', 'https://adv.example/p?lsclk=keepme', 0), camp(4, A1, 'QA odd target', 'adv.example/no-scheme', 0), camp(5, A2, 'QA other', 'https://other.example/', 50)]; + camp(3, A1, 'QA has lsclk', 'https://adv.example/p?lsclk=keepme', 0), camp(4, A1, 'QA odd target', 'adv.example/no-scheme', 0), camp(5, A2, 'QA other', 'https://other.example/', 50), + Object.assign(camp(6, A1, 'QA old no log', 'https://adv.example/old', 500), { created: now - 60 * 86400000 }), Object.assign(camp(7, A1, 'QA new no log', 'https://adv.example/new', 90), { created: now - 3 * 86400000 })]; +// cost per goal (30 days): campaign 1 spent 150 today + 50 five days ago inside the window, 100 forty days ago outside it +const ctd = t => new Date(t).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }); +const cl = (t, delta, ref) => ({ email: A1, ts: t, day: ctd(t), delta, kind: 'delivery', note: 'Ad views: QA landing', ref: String(ref) }); +fs.writeFileSync(path.join(DATA, 'credit-log.json'), JSON.stringify({ items: [cl(now - 40 * 86400000, -100, 1), cl(now - 5 * 86400000, -50, 1), cl(now - 60000, -150, 1), Object.assign(cl(now - 60000, -999, 1), { email: A2 })] })); fs.writeFileSync(path.join(DATA, 'campaigns.json'), JSON.stringify({ v: 1, nextId: 6, campaigns: CAMPS, burnsPending: [] })); // ---- mock LinkSpin ---- const PX1 = 'px0123456789', PX2 = 'pxabcdef0123'; -const mock = { clicks: new Map(), badSig: 0, calls: [], down: false, goals: { [A1]: [{ px: PX1, name: 'subscriber', value: null, created: now - 86400000, conv: 6, convDays: 30, lastAt: now - 3600000, lastTest: null }, { px: PX2, name: 'sale', value: 19.95, created: now - 86400000, conv: 1, convDays: 30, lastAt: now - 7200000, lastTest: null }] } }; +const mock = { clicks: new Map(), owners: [], badSig: 0, calls: [], down: false, goals: { [A1]: [{ px: PX1, name: 'subscriber', value: null, created: now - 86400000, conv: 6, convDays: 30, lastAt: now - 3600000, lastTest: null }, { px: PX2, name: 'sale', value: 19.95, created: now - 86400000, conv: 1, convDays: 30, lastAt: now - 7200000, lastTest: null }] } }; const verify = (ts, sig, raw) => { if (!ts || !sig || Math.abs(Date.now() - Number(ts)) > 300000) return false; const want = crypto.createHmac('sha256', SECRET).update(ts + '\n' + raw).digest('hex'); return want.length === String(sig).length && crypto.timingSafeEqual(Buffer.from(want), Buffer.from(String(sig))); }; const send = (res, code, obj) => { res.writeHead(code, { 'Content-Type': 'application/json' }); res.end(JSON.stringify(obj)); }; function mockHandler(req, res) { @@ -52,11 +60,11 @@ function mockHandler(req, res) { if (req.method !== 'POST') return send(res, 404, { error: 'not found' }); if (!verify(req.headers['x-ls-ts'], req.headers['x-ls-sig'], raw)) { mock.badSig++; return send(res, 401, { error: 'bad signature' }); } const b = JSON.parse(raw || '{}'); - if (req.url === '/api/partner/clicks') { for (const c of b.clicks || []) mock.clicks.set(c.id, c); return send(res, 200, { ok: true, n: (b.clicks || []).length }); } + if (req.url === '/api/partner/clicks') { for (const c of b.clicks || []) mock.clicks.set(c.id, c); for (const o of b.owners || []) mock.owners.push(o); return send(res, 200, { ok: true, n: (b.clicks || []).length, owners: (b.owners || []).length }); } if (req.url === '/api/partner/conv') { mock.calls.push(b); const email = String(b.email || ''); const goals = mock.goals[email] || (mock.goals[email] = []); - if (b.op === 'summary') return send(res, 200, { ok: true, goals, byCampaign: email === A1 ? { 1: { clicks: 9, conv: { [PX1]: 4, [PX2]: 1 }, value: { [PX2]: 19.95 } }, 2: { clicks: 3, conv: {} } } : {}, methods: { url: 2, stored: 2, cookie: 1, soft: 1 }, host: 'linkspin.app' }); + if (b.op === 'summary') return send(res, 200, { ok: true, goals, byCampaign: email === A1 ? { 1: { clicks: 9, conv: { [PX1]: 4, [PX2]: 1 }, value: { [PX2]: 19.95 } }, 2: { clicks: 3, conv: {} }, 6: { clicks: 4, conv: { [PX1]: 2 } }, 7: { clicks: 5, conv: { [PX1]: 3 } } } : {}, methods: { url: 2, stored: 2, cookie: 1, soft: 1 }, selfTests: email === A1 ? 3 : 0, host: 'linkspin.app' }); if (b.op === 'create') { const g = { px: 'px' + crypto.randomBytes(5).toString('hex'), name: b.name, value: b.value == null ? null : b.value, created: Date.now(), conv: 0, convDays: 30, lastAt: null, lastTest: null }; goals.push(g); return send(res, 200, { ok: true, goal: g }); } if (b.op === 'remove') { const i = goals.findIndex(g => g.px === b.px); if (i < 0) return send(res, 404, { error: 'No such goal.' }); goals.splice(i, 1); return send(res, 200, { ok: true }); } if (b.op === 'test') { const g = goals.find(x => x.px === b.px); if (!g) return send(res, 404, { error: 'No such goal.' }); g.lastTest = Date.now(); return send(res, 200, { ok: true, at: g.lastTest }); } @@ -126,10 +134,22 @@ try { const after = (await api('/api/my/campaigns', null, { Cookie: ck1 })).j; const clicksAfter = ((after && after.campaigns) || []).find(c => c.id === 1); ok(clicksBefore && clicksAfter && clicksAfter.clicks === clicksBefore.clicks && clicksBefore.clicks === 2, 'own click not counted (clicks stay 2)', JSON.stringify([clicksBefore && clicksBefore.clicks, clicksAfter && clicksAfter.clicks])); + // fix 1 (2026-10-26): the soft keys the owner signs in from go to LinkSpin as owners; a click from that browser while + // signed out is flagged self for conversions (billing unchanged: it is still a counted click) + const skNode = ['127.0.0.1', '::ffff:127.0.0.1'].map(x => 's:' + crypto.createHash('sha256').update(x + '|node').digest('hex').slice(0, 20)); + ok(!!(await waitFor(() => mock.owners.some(o => o.owner === A1 && skNode.includes(o.sk)), 10000)), "owner's session soft key pushed to LinkSpin as owners (no raw IP)", JSON.stringify(mock.owners)); + ok(!JSON.stringify(mock.owners).includes('127.0.0.1'), 'no raw IP in the owners rows'); + const ownSk = await click(1, { 'User-Agent': 'node' }); const idOwnSk = (ID.exec(ownSk.loc || '') || [])[1]; + ok(!!(await waitFor(() => mock.clicks.get(idOwnSk), 10000)) && mock.clicks.get(idOwnSk).self === 1, "a click from the owner's own browser, signed out, is pushed self=1", JSON.stringify(mock.clicks.get(idOwnSk))); + const strangerC = await click(1, { 'User-Agent': 'Mozilla/5.0 Stranger QA' }); const idStr = (ID.exec(strangerC.loc || '') || [])[1]; + ok(!!(await waitFor(() => mock.clicks.get(idStr), 10000)) && mock.clicks.get(idStr).self === 0, "a stranger's click is still self=0"); + const nOwners = mock.owners.length; await api('/api/my/campaigns', null, { Cookie: ck1 }); await sleep(3500); + ok(mock.owners.length === nOwners, 'the same session soft key is not pushed again within 6 h'); // 4. proxies const sum = await api('/api/my/conversions', null, { Cookie: ck1 }); ok(sum.j && sum.j.ok === true && sum.j.goals.length === 2 && sum.j.byCampaign['1'].conv[PX1] === 4, 'GET /api/my/conversions relays the LinkSpin summary', JSON.stringify(sum.j).slice(0, 200)); + ok(sum.j && sum.j.spend30 && sum.j.spend30['1'] === 200 && sum.j.spend30['6'] == null && sum.j.spend30['7'] == null && sum.j.spendSince > Date.now() - 31 * 86400000, 'spend30 from the credit log: campaign 1 = 150 + 50 inside the 30 days (the 100 from 40 days ago and another member\'s row left out)', JSON.stringify(sum.j && sum.j.spend30)); const lastSum = mock.calls.filter(c => c.op === 'summary').pop(); ok(lastSum && lastSum.email === A1 && lastSum.days === 30, 'summary asked for the signed-in email, 30 days', JSON.stringify(lastSum)); const nSum = mock.calls.filter(c => c.op === 'summary').length; await api('/api/my/conversions', null, { Cookie: ck1 }); @@ -163,6 +183,7 @@ try { rows: document.querySelectorAll('#campList .camp-table tbody tr').length, line1: (document.querySelector('[data-convcamp="1"]') || {}).textContent || '', line1Hidden: !!(document.querySelector('[data-convcamp="1"]') || {}).hidden, line5Hidden: (document.querySelector('[data-convcamp="5"]') || { hidden: true }).hidden, + line6: (document.querySelector('[data-convcamp="6"]') || {}).textContent || '', line7: (document.querySelector('[data-convcamp="7"]') || {}).textContent || '', title1: (document.querySelector('[data-convcamp="1"]') || {}).title || '', card: !document.getElementById('convCard').hidden, status: document.getElementById('convStatus').textContent, goals: document.querySelectorAll('#convGoals tbody tr').length, convCells: [...document.querySelectorAll('#convGoals td[data-l="Conversions (30 days)"]')].map(td => (td.firstChild && td.firstChild.textContent || '').trim()), landing: (document.getElementById('convLanding') || {}).value || '', img: (document.getElementById('convImg') || {}).value || '', js: (document.getElementById('convJs') || {}).value || '', tip: document.getElementById('convCard').textContent })); @@ -171,7 +192,11 @@ try { } const p1 = await pane(ck1, 'convpixel-pane.png'); ok(p1.st.rows >= 4 && p1.st.card, 'Campaigns pane loads with the Conversion tracking card', JSON.stringify(p1.st).slice(0, 200)); - ok(!p1.st.line1Hidden && /subscriber 4 \(75 credits each\)/.test(p1.st.line1) && /sale 1 \(300 credits each\)/.test(p1.st.line1), 'campaign row shows goals + cost per goal (300 / 4 = 75 credits)', p1.st.line1); + ok(!p1.st.line1Hidden && /cost per goal \(30 days\)/.test(p1.st.line1) && /subscriber 4 \(50 credits each\)/.test(p1.st.line1) && /sale 1 \(200 credits each\)/.test(p1.st.line1), 'campaign row: cost per goal (30 days) = 200 credits spent in the 30 days / 4 = 50 (not lifetime 300 / 4 = 75)', p1.st.line1); + ok(/same 30 days/.test(p1.st.title1), 'its tooltip says the spend is the same 30 days', p1.st.title1); + ok(/subscriber 2/.test(p1.st.line6) && !/credits each/.test(p1.st.line6) && /no spend on record/.test(p1.st.line6), 'an older campaign with no spend in the log shows no cost per goal rather than a lifetime figure', p1.st.line6); + ok(/subscriber 3 \(30 credits each\)/.test(p1.st.line7), 'a campaign started inside the window with no log rows uses its spend since start (90 / 3 = 30)', p1.st.line7); + ok(/3 from your own clicks, kept as tests/.test(p1.st.status), 'card shows the own-click test count (selfTests from LinkSpin)', p1.st.status); ok(!/\$/.test(p1.st.line1), 'cost per goal is in credits, never dollars'); ok(JSON.stringify(p1.st.convCells) === '["6","1"]', 'goal rows show the conversion count, not the 30-day window (convDays is the window length)', JSON.stringify(p1.st.convCells)); ok(p1.st.goals === 2 && p1.st.landing === '', 'goal list + landing tag snippet', p1.st.landing); @@ -179,6 +204,35 @@ try { ok(/Thank You Page: custom page/.test(p1.st.tip) && /Thank-you page: custom URL/.test(p1.st.tip) && /24-hour match/.test(p1.st.tip), 'autoresponder advice + match legend present'); ok(/url 2, stored 2, cookie 1, soft 1/.test(p1.st.status), 'match methods line', p1.st.status); ok(!p1.errs.length, 'no page errors', p1.errs.join(' | ')); + // fix 2 (2026-10-26): Send a test conversion loads the REAL pixel in test mode. The browser's request to linkspin.app is + // routed here (nothing leaves the machine): PX1 answers X-LS-Result: test like LinkSpin; PX2 answers unknown, so the + // card falls back to the signed partner call (op test). + { + const ctx = await browser.newContext({ viewport: { width: 1280, height: 1000 } }); + await ctx.addInitScript(() => { try { sessionStorage.setItem('iap.welcome.v1', '1'); } catch (e) {} }); + const [k, v] = ck1.split(';')[0].split('='); await ctx.addCookies([{ name: k, value: v, url: B }]); + const pixelHits = []; + await ctx.route(/^https:\/\/linkspin\.app\/cv\.gif/, route => { const u = new URL(route.request().url()); pixelHits.push(u.search); const px = u.searchParams.get('px'); const g = (mock.goals[A1] || []).find(x => x.px === px); + const good = px === PX1 && u.searchParams.get('test') === '1' && g; if (good) g.lastTest = Date.now(); + return route.fulfill({ status: 200, headers: { 'Content-Type': 'image/gif', 'Access-Control-Allow-Origin': '*', 'Access-Control-Expose-Headers': 'X-LS-Result', 'X-LS-Result': good ? 'test' : 'unknown' }, body: Buffer.from('R0lGODlhAQABAAAAACw=', 'base64') }); }); + const page = await ctx.newPage(); const errs = []; page.on('pageerror', e => errs.push(e.message)); + await page.goto(B + '/my', { waitUntil: 'domcontentloaded' }); await page.waitForTimeout(2500); + await page.evaluate(() => { document.querySelectorAll('.modal-back,.lgate,.iap-welcome').forEach(m => m.hidden = true); }); + await page.click('.bo-menu [data-pane="campaigns"]'); await page.waitForTimeout(2500); + const testsBefore = mock.calls.filter(c => c.op === 'test').length; + await page.click('[data-convtest="' + PX1 + '"]'); await page.waitForTimeout(2000); + const msg1 = await page.evaluate(() => document.body.innerText); + const last1 = await page.evaluate(px => { const b = document.querySelector('[data-convtest="' + px + '"]'); const tr = b && b.closest('tr'); const td = tr && tr.querySelector('td[data-l="Last test"]'); return td ? td.textContent.trim() : ''; }, PX1); + ok(pixelHits.some(q => q.includes('px=' + PX1) && q.includes('test=1')), 'Send a test conversion loads the real pixel cv.gif?px=..&test=1 from the browser', JSON.stringify(pixelHits)); + ok(/received by your real pixel/.test(msg1) && last1 && last1 !== 'never' && mock.calls.filter(c => c.op === 'test').length === testsBefore, 'pixel answered test: Last test updates, no partner fallback needed', last1); + await page.click('[data-convtest="' + PX2 + '"]'); await page.waitForTimeout(2000); + const msg2 = await page.evaluate(() => document.body.innerText); + const tcall = mock.calls.filter(c => c.op === 'test').pop(); + ok(pixelHits.some(q => q.includes('px=' + PX2)) && tcall && tcall.px === PX2 && /recorded through InstantAdPay/.test(msg2), 'pixel did not confirm: falls back to the signed partner call (op test)', JSON.stringify(tcall)); + ok(!errs.length, 'no page errors during the tests', errs.join(' | ')); + await page.screenshot({ path: path.join(OUT, 'convpixel-test-button.png'), fullPage: true }).catch(() => {}); + await ctx.close(); + } // 6. LinkSpin down: the pane still loads, the panel says so, campaign rows omit the goal line; clicks are kept and pushed later mock.down = true; diff --git a/server.js b/server.js index 6f3beaf..c1a1527 100644 --- a/server.js +++ b/server.js @@ -522,6 +522,7 @@ async function boot() { marks.init({ db }); marks.ensureTable().catch(e => console.error('marks table', e.message)); lsconv.init({ db, dataDir: DATA_DIR }); + auth.onSeen((email, req) => lsconv.noteSession(email, clientIp(req), req.headers['user-agent'])); // own-click tests on LinkSpin (2026-10-26) setInterval(() => marks.prune().catch(() => {}), 6 * 3600 * 1000).unref(); chain.init({ onEvent: ev => { // the in-memory feed is per instance and always runs @@ -814,7 +815,7 @@ const MIME = { '.html': 'text/html; charset=utf-8', '.css': 'text/css', '.js': ' '.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml', '.webp': 'image/webp', '.ico': 'image/x-icon', '.json': 'application/json', '.mp4': 'video/mp4', '.woff2': 'font/woff2', '.gif': 'image/gif', '.webm': 'video/webm', '.vtt': 'text/vtt; charset=utf-8', '.txt': 'text/plain; charset=utf-8', '.xml': 'application/xml; charset=utf-8' }; -const CSP = "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net https://www.networkadspace.com https://networkadspace.com https://polhunter.com 'sha256-NzvNrqk5jB9YZATwo5BF4JoRlJ02HsnFikbKXgEPdaQ='; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: blob: https:; media-src 'self' https: blob:; connect-src 'self' https://polhunter.com https://*.walletconnect.com wss://*.walletconnect.com https://*.walletconnect.org wss://*.walletconnect.org https://*.reown.com wss://*.reown.com https://*.reown.org wss://*.reown.org https://*.web3modal.org https://*.drpc.org https://*.publicnode.com https://*.coinbase.com; font-src 'self' data: https://fonts.gstatic.com https://fonts.reown.com; form-action 'self'; frame-src https: http:"; +const CSP = "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net https://www.networkadspace.com https://networkadspace.com https://polhunter.com 'sha256-NzvNrqk5jB9YZATwo5BF4JoRlJ02HsnFikbKXgEPdaQ='; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: blob: https:; media-src 'self' https: blob:; connect-src 'self' https://polhunter.com https://*.walletconnect.com wss://*.walletconnect.com https://*.walletconnect.org wss://*.walletconnect.org https://*.reown.com wss://*.reown.com https://*.reown.org wss://*.reown.org https://*.web3modal.org https://*.drpc.org https://*.publicnode.com https://*.coinbase.com https://linkspin.app; font-src 'self' data: https://fonts.gstatic.com https://fonts.reown.com; form-action 'self'; frame-src https: http:"; function baseHeaders(extra) { return Object.assign({ 'Content-Security-Policy': CSP, 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin' }, extra || {}); @@ -4766,7 +4767,9 @@ const server = http.createServer(async (req, res) => { // conversion tracking (2026-10-23): every click, the owner's own too (flagged self, so they can test), gets a click id // on the target URL as lsclk=; the row goes to LinkSpin, which matches the advertiser's goal pixel to it let loc = target; - if (cm) { try { const ip = clientIp(req); const row = await lsconv.record(cm, req, { self: own, target, ip, country: geo.countryOf(ip) || null }); loc = lsconv.withClickId(target, row.id); } catch (e) { console.error('lsconv record', e.message); } } + // self for conversion tracking (2026-10-26): signed in as the owner, OR from a browser the owner signs in from (soft + // key). Only the conversion side; whether the click is counted and billed above stays the signed-in check. + if (cm) { try { const ip = clientIp(req); const selfConv = own || lsconv.isOwnerSk(cm.owner, lsconv.softKey(ip, req.headers['user-agent'])); const row = await lsconv.record(cm, req, { self: selfConv, target, ip, country: geo.countryOf(ip) || null }); loc = lsconv.withClickId(target, row.id); } catch (e) { console.error('lsconv record', e.message); } } res.writeHead(302, baseHeaders({ Location: loc })); return res.end(); } @@ -4808,7 +4811,11 @@ const server = http.createServer(async (req, res) => { const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' }); if (!lsconv.on()) return json(res, 200, { ok: false, reason: 'off', error: 'Conversion tracking is not switched on yet. Your ads and clicks work as usual.' }); - try { return json(res, 200, Object.assign({}, await lsconv.summary(s.email, u.searchParams.get('fresh') === '1'), { ok: true })); } + // cost per goal (30 days), 2026-10-26: the goals are LinkSpin's last 30 days, so the spend beside them is each + // campaign's spend over the same 30 days from the credit activity log (spend30), not its lifetime total + const since = Date.now() - 30 * 86400000; let sp = null; + try { sp = await ads.spendSince(s.email, since); } catch (e) { console.error('spendSince', e.message); } + try { return json(res, 200, Object.assign({}, await lsconv.summary(s.email, u.searchParams.get('fresh') === '1'), { ok: true, spendSince: since, spendDay: sp ? sp.day : null, spend30: sp ? sp.byCampaign : null })); } catch (e) { return json(res, 200, { ok: false, reason: 'down', error: 'LinkSpin, the service that counts your conversions, did not answer just now. Your ads and clicks are fine. Try again in a minute.' }); } } if ((p === '/api/my/conversions/goal' || p === '/api/my/conversions/test') && req.method === 'POST') {