Campaigns > Conversion tracking panel: goals (name, default value, pixel id, 30-day conversions, last test), add goal, landing tag + goal pixel snippets (JS version under a toggle), Send a test conversion, autoresponder thank-you page advice, how-sure legend; each campaign row shows goals and cost per goal in credits from the LinkSpin summary. LinkSpin down: the card says so, the rows omit the goal line. my.js?v=20261023cv

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-23 18:01:08 -05:00
parent 46bb7dd9dd
commit ce977698b9
2 changed files with 116 additions and 3 deletions
+88 -2
View File
@@ -1063,6 +1063,90 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
pageList('credits', box, 'tbody tr');
} catch (e) {}
}
// Campaigns > Conversion tracking (2026-10-23). Goals and counts come from LinkSpin through /api/my/conversions. Anything
// going wrong here only changes this card's own text: the campaign list never depends on it.
let convSel = null, convCamps = [];
const convFmt = n => Number(n || 0).toLocaleString(undefined, { maximumFractionDigits: 1 });
function convSnips(host, g) {
const h = 'https://' + String(host || 'linkspin.app').replace(/^https?:\/\//, '').replace(/\/+$/, '');
const px = encodeURIComponent(g.px), goal = encodeURIComponent(g.name);
const val = g.value != null && g.value !== '' ? '&value=' + encodeURIComponent(g.value) : '';
return {
landing: '<script async src="' + h + '/t.js?px=' + px + '"></' + 'script>',
img: '<img src="' + h + '/cv.gif?px=' + px + '&goal=' + goal + val + '" width="1" height="1" alt="" style="display:none">',
js: '<script async src="' + h + '/cv.js?px=' + px + '&goal=' + goal + val + '"></' + 'script>'
};
}
const convBox = (id, label, text) => '<p class="small" style="margin:10px 0 4px"><b>' + label + '</b> <button class="btn small sec" type="button" data-convcopy="' + id + '">Copy</button></p>'
+ '<textarea id="' + id + '" readonly rows="2" style="width:100%;font-family:var(--mono);font-size:12px">' + esc(text) + '</textarea>';
function convCampLines(d) {
document.querySelectorAll('[data-convcamp]').forEach(el => { el.hidden = true; el.innerHTML = ''; });
if (!d || !d.ok || !(d.goals || []).length) return;
const by = d.byCampaign || {};
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);
const parts = d.goals.map(g => { const n = Number(b && b.conv && b.conv[g.px]) || 0;
return '<span>' + esc(g.name) + ' ' + n.toLocaleString() + (n > 0 ? ' (' + convFmt(spent / n) + ' credits each)' : '') + '</span>'; });
el.innerHTML = '\u{1F3AF} ' + parts.join(' · ') + (b && b.clicks ? ' <span class="muted">· ' + Number(b.clicks).toLocaleString() + ' tracked clicks</span>' : '');
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.';
el.hidden = false;
});
}
async function loadConv(fresh) {
const card = $('convCard'); if (!card) return;
card.hidden = false;
let d = null;
try { d = await (await fetch('/api/my/conversions' + (fresh ? '?fresh=1' : ''))).json(); } catch (e) { d = { ok: false, error: 'Could not reach InstantAdPay just now. Try again in a minute.' }; }
convCampLines(d);
const st = $('convStatus'), list = $('convGoals'), snips = $('convSnips'), add = $('convAddRow');
if (!d || !d.ok) { st.textContent = (d && d.error) || 'Conversion tracking is not available right now.'; list.innerHTML = ''; snips.innerHTML = ''; add.hidden = !!(d && d.reason === 'off'); return; }
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.';
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';
list.innerHTML = '<div class="tablewrap"><table class="camp-table"><thead><tr><th>Goal</th><th class="num">Default value</th><th>Pixel id</th><th class="num">Conversions (30 days)</th><th>Last test</th><th></th></tr></thead><tbody>'
+ goals.map(g => '<tr' + (g.px === convSel ? ' style="background:rgba(120,160,255,.08)"' : '') + '><td data-l="Goal"><b>' + esc(g.name) + '</b></td>'
+ '<td class="num" data-l="Default value">' + (g.value != null && g.value !== '' ? esc(g.value) : '<span class="muted">none</span>') + '</td>'
+ '<td data-l="Pixel id" class="mono small">' + esc(g.px) + '</td>'
+ '<td class="num" data-l="Conversions (30 days)">' + Number(g.convDays != null ? g.convDays : g.conv || 0).toLocaleString() + (g.lastAt ? '<div class="muted small">last ' + when(g.lastAt) + '</div>' : '') + '</td>'
+ '<td data-l="Last test" class="small">' + when(g.lastTest) + '</td>'
+ '<td class="act"><button class="btn small sec" type="button" data-convpick="' + esc(g.px) + '">Snippets</button> <button class="btn small sec" type="button" data-convtest="' + esc(g.px) + '">Send a test conversion</button> <button class="btn small quiet" type="button" data-convdel="' + esc(g.px) + '" data-convname="' + esc(g.name) + '">Remove</button></td></tr>').join('')
+ '</tbody></table></div>';
const g = goals.find(x => x.px === convSel); const sn = convSnips(d.host, g);
snips.innerHTML = '<h4 style="margin:14px 0 0">Snippets for <b>' + esc(g.name) + '</b></h4>'
+ convBox('convLanding', '1. Landing tag (the page your ad points to)', sn.landing)
+ convBox('convImg', '2. Goal pixel (your thank-you page)', sn.img)
+ '<details style="margin-top:8px"><summary class="small">Prefer the JS version of the goal pixel?</summary>'
+ '<p class="small muted" style="margin:6px 0 0">Use it where your page allows scripts. It also sends the click id the landing tag stored, which makes the count surer.</p>'
+ convBox('convJs', 'Goal pixel, JS version', sn.js) + '</details>';
list.querySelectorAll('[data-convpick]').forEach(b => b.addEventListener('click', () => { convSel = b.dataset.convpick; loadConv(); }));
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; }
}));
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' });
if (!yes) return; b.disabled = true;
try { await api('/api/my/conversions/goal', { op: 'remove', px: b.dataset.convdel }); IAP.status('Goal removed.', 'ok'); await loadConv(true); }
catch (e) { IAP.status(e.message, 'bad'); b.disabled = false; }
}));
snips.querySelectorAll('[data-convcopy]').forEach(b => b.addEventListener('click', async () => {
const ta = $(b.dataset.convcopy); try { await navigator.clipboard.writeText(ta.value); IAP.status('Copied. Paste it into your page.', 'ok'); } catch (e) { ta.select(); IAP.status('Selected. Press Ctrl+C (or long-press, Copy) to copy it.', 'ok'); }
}));
}
if ($('convAddBtn')) $('convAddBtn').addEventListener('click', async () => {
const b = $('convAddBtn'); const name = $('convName').value.trim(); const value = $('convValue').value.trim();
if (!name) { IAP.status('Give the goal a short name, like subscriber or sale.', 'bad'); return; }
b.disabled = true;
try { const r = await api('/api/my/conversions/goal', { op: 'create', name, value }); if (r.goal && r.goal.px) convSel = r.goal.px; $('convName').value = ''; $('convValue').value = ''; IAP.status('Goal added. Copy its two snippets below.', 'ok'); await loadConv(true); }
catch (e) { IAP.status(e.message, 'bad'); }
b.disabled = false;
});
async function loadCampaigns() {
try {
const r = await (await fetch('/api/my/campaigns')).json();
@@ -1093,12 +1177,13 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
+ (r.rates.soloCostPerRecipient || 5) + 'cr/delivery';
const el = $('campList');
el.innerHTML = '';
if (!r.campaigns.length) { el.innerHTML = '<p class="muted small">No campaigns yet. Launch your first below.</p>'; loadCreditActivity(el); return; }
convCamps = r.campaigns || [];
if (!r.campaigns.length) { el.innerHTML = '<p class="muted small">No campaigns yet. Launch your first below.</p>'; loadCreditActivity(el); loadConv(); return; }
const tbl = document.createElement('div');
tbl.className = 'tablewrap';
tbl.innerHTML = '<table class="camp-table"><thead><tr><th>Name</th><th>Type</th><th class="num">Views here</th><th class="num" title="Impressions delivered by Network Ad Space across the wider network (banner and text ads only)">Network views</th><th class="num">Clicks</th>'
+ '<th class="num">Spent</th><th class="num">Budget</th><th>Status</th><th></th></tr></thead><tbody>'
+ r.campaigns.map(c => '<tr><td data-l="Campaign"><b>' + c.name + '</b>' + hourBars(r.hours && r.hours[c.id]) + geoLine(r.geo && r.geo[c.id]) + '</td>'
+ r.campaigns.map(c => '<tr><td data-l="Campaign"><b>' + c.name + '</b>' + hourBars(r.hours && r.hours[c.id]) + geoLine(r.geo && r.geo[c.id]) + '<div class="muted small conv-line" data-convcamp="' + c.id + '" hidden></div></td>'
+ '<td data-l="Type">' + c.type + (c.type === 'banner' && c.width ? ' <span class="muted small">' + c.width + '×' + c.height + '</span>' : '') + (c.dailyCap ? ' <span class="muted small" title="daily cap: ' + c.dailyCap + ' credits, ' + (c.daySpent || 0) + ' spent today">cap ' + c.dailyCap + '/day</span>' : '') + (c.geo ? ' <span class="muted small" title="shown only to viewers in these country tiers">tier ' + esc(c.geo.replace(/,/g, '+')) + '</span>' : '') + schedChips(c)
+ (c.type === 'visits' && (c.placement === 'golden' || c.placement === 'doors') ? ' <span class="badge' + (c.placement === 'golden' ? ' amber' : '') + '" title="' + (c.doorOnly ? 'runs only in Spooky Doors until the season ends, then any doors left run as normal visits' : 'the Spooky Doors season is over, so any doors left run as normal visits') + '">' + (c.placement === 'golden' ? 'Golden Door' : 'Spooky Doors') + '</span>' : '') + '</td>'
+ '<td class="num" data-l="Views here">' + c.imps.toLocaleString() + '</td>'
@@ -1120,6 +1205,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
+ '</td></tr>').join('') + '</tbody></table>';
el.appendChild(tbl);
pageList('camps', tbl, 'tbody tr');
loadConv();
renderArchived(el, r);
const note = document.createElement('p'); note.className = 'muted small';
note.textContent = 'Credits you put into a campaign are set aside the moment you start it, so your Available number drops right away and the campaign spends from its own budget. Featured links and verified-visit packs are paid in full up front; a featured run is sold by the day, so use Extend run to keep it going. Whatever a campaign has not spent comes back to Available when it ends.';
+28 -1
View File
@@ -618,6 +618,33 @@
</div>
<button class="btn" id="createCampBtn">Launch campaign</button>
</div>
<div class="card" id="convCard" hidden>
<h3>Conversion tracking</h3>
<p class="muted small">See which of your ads bring subscribers and sales, not just clicks. Every click on your ad carries a click id. Put two small tags on your own site and each goal is counted against the ad that sent the visitor, with a cost per goal in credits on each campaign above. The counting is done by LinkSpin, our sister site, under this same email.</p>
<ol class="small" style="margin:6px 0 10px 18px;padding:0">
<li>Add a goal below, for example <b>subscriber</b> or <b>sale</b>.</li>
<li>Put the <b>landing tag</b> on the page your ad sends people to (once per page, just before &lt;/body&gt;).</li>
<li>Put the <b>goal pixel</b> on your thank-you page, the page people see after they sign up or buy.</li>
</ol>
<p class="small" id="convStatus"></p>
<div id="convGoals"></div>
<div id="convAddRow" class="grid c3" style="margin-top:10px">
<p><input id="convName" maxlength="32" placeholder="Goal name, like subscriber or sale" style="width:100%"></p>
<p><input id="convValue" type="number" min="0" step="0.01" placeholder="Default value (optional), like 19.95" style="width:100%"></p>
<p><button class="btn small" id="convAddBtn" type="button">Add goal</button></p>
</div>
<div id="convSnips"></div>
<h4 style="margin:14px 0 4px">Your autoresponder's thank-you page</h4>
<p class="small muted" style="margin:0">Set your autoresponder's thank-you (success) page to a page on YOUR site that carries the goal pixel. Aweber: in your sign-up form settings, choose 'Thank You Page: custom page' and paste your page's address. GetResponse: in the form or landing page settings, pick 'Thank-you page: custom URL' and paste your page's address. If you cannot change it, the pixel can still count through the cookie or the 24-hour match, just less surely.</p>
<h4 style="margin:14px 0 4px">How sure is each count</h4>
<ul class="small muted" id="convLegend" style="margin:0 0 0 18px;padding:0">
<li><b>Click id in the address</b> (url): surest. The thank-you page address still carried the click id from your ad.</li>
<li><b>Stored by the landing tag</b> (stored): very sure. The landing tag kept the click id on your site and the goal pixel read it back.</li>
<li><b>LinkSpin cookie</b> (cookie): fairly sure. Matched through LinkSpin's own cookie in the visitor's browser. Some browsers block it.</li>
<li><b>24-hour match</b> (soft): least sure. Same connection and browser within 24 hours of a click. A good guess, not a proof.</li>
</ul>
<p class="small muted" style="margin:8px 0 0">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.</p>
</div>
<div class="card ad-foot" id="adSlotPane-campaigns" hidden></div>
</div>
@@ -1189,7 +1216,7 @@
<script src="/assets/wallet.js?v=20260911a"></script>
<script src="/assets/promo.js?v=20261016p"></script>
<script src="/assets/support.js?v=20261016a"></script>
<script src="/assets/my.js?v=20261023ov"></script>
<script src="/assets/my.js?v=20261023cv"></script>
<script src="/assets/chat.js?v=20261016n"></script>
</body>
</html>