Traffic sources: network macros, campaign URLs, per-source postbacks, Reports dimension
A Source is a first-class record of a network a member buys traffic on (PropellerAds,
Zeropark, Adsterra, ExoClick and 25 more from the shipped catalog, or defined by hand).
It remembers the network's macro tokens and conversion postback, attaches to spin links,
builds the exact campaign URL to paste into the network, fires that network's own
postback only for clicks that came through it, and shows up in Reports by source and
by the zone / placement / site the macro carried.
- data/traffic-sources.json: catalog of 29 networks (BeMob template harvest), un-ignored
via data/* + !data/traffic-sources.json; loader tolerates missing fields, null costModel,
{{slot}} labels with spaces and parentheses, optional slots, unknown single-brace macros
- sources.js: DATA_DIR/sources.json model, 30 per account, 20 params, key allow-list,
postbacks.validateUrl on the filled postback; list/create/update/get/urlFor/test
- rotator.js: update() takes sourceId (owner-checked), pub() exposes it, hits and conversions
are stamped with the source at click time (sr), wider query allow-list (cost, creative,
site, banner, keyword, geo, os, browser, device, carrier, format, external_id, visitor_id),
summary() adds sources[] and placements[], sourceCounts(), detachSource()
- postbacks.js: fire() delivers the matching source's postback after the manual ones through
the same deliver() (guards, retry, rate cap, auto-disable); log rows carry source; convertFor,
inbound and the page lead path pass sourceId; fill/deliver/logForSource exported
- routes (GET and POST): /api/sources/catalog, /api/my/sources, /api/my/sources/<id>,
/api/my/sources/<id>/url; /sources screen
- /sources Control Room screen (list + Campaign URL / Postback / Settings tabs, two-step
New source dialog); Links share kit gets a source select and a "Campaign URL for <network>"
first row; Reports gets Traffic sources and Placements; rail entry; chatbot canned answer,
FACTS line and KNOWLEDGE_DATE 2026-10-12
- cr.css: phone rail icons only at 34px so ten entries fit; cache tags bumped to 20261012a
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+10
-4
@@ -1,7 +1,7 @@
|
||||
// LinkSpin Links workspace (Control Room). Rotator API + postbacks + share kit. Uses the shared shell (cr-shell.js).
|
||||
(function () {
|
||||
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt, api = CR.api, toast = CR.toast, dialog = CR.dialog;
|
||||
let ROT = [], HOSTS = [], SEL = null, STATS = {}, FILTER = '', PB = null;
|
||||
let ROT = [], HOSTS = [], SEL = null, STATS = {}, FILTER = '', PB = null, SRC = []; // SRC = the member's traffic sources (sources.js, 2026-10-12)
|
||||
CR.mount({ active: 'links', title: 'Links', sub: 'loading', actions: '<button class="btn pri" id="newBtn" type="button">+ New spin</button>' });
|
||||
const linkUrl = r => 'https://' + (HOSTS[0] || location.host) + '/r/' + r.code;
|
||||
const clicks7 = r => r.hits7 || 0;
|
||||
@@ -72,6 +72,7 @@
|
||||
let r; try { r = await CR.get('/api/my/rotations'); } catch (e) { CR.sub('could not load'); return; }
|
||||
ROT = (r.rotations || []).slice().sort((a, b) => clicks7(b) - clicks7(a)); HOSTS = r.hosts || [];
|
||||
try { const lh = await api('/api/my/link-hosts'); LH = (lh && lh.hosts) || []; } catch (e) { LH = []; } // link domains by channel (domains.js, 2026-10-10)
|
||||
try { SRC = (await CR.get('/api/my/sources')).sources || []; } catch (e) { SRC = []; }
|
||||
const tot7 = ROT.reduce((n, x) => n + clicks7(x), 0);
|
||||
CR.sub(ROT.length + ' link' + (ROT.length === 1 ? '' : 's') + ' · ' + fmt(tot7) + ' clicks in 7 days');
|
||||
renderList();
|
||||
@@ -137,14 +138,19 @@
|
||||
function renderShare(r) {
|
||||
const url = linkUrl(r);
|
||||
const byChannel = LH.filter(h => h.channel !== 'reserve').map(h => ['Best link for ' + (h.label || h.channel), 'https://' + h.host + '/r/' + r.code + (h.note ? ' (' + h.note + ')' : '')]);
|
||||
const kit = byChannel.concat([
|
||||
// traffic source (2026-10-12): when the link is pointed at one, the first row is the exact campaign URL for that network
|
||||
const src = SRC.find(s => s.id === r.sourceId) || null;
|
||||
const campaign = src ? [['Campaign URL for ' + src.name, url + ((src.params || []).length ? '?' + src.params.map(p => p.key + '=' + p.token).join('&') : '')]] : [['Tracker-ready link', url + '?clickid={clickid}&s1={source} (replace the braces with your network\'s macros)']];
|
||||
const kit = campaign.concat(byChannel, [
|
||||
['Short post', 'One link, every page I promote, in turn. Take a look: ' + url],
|
||||
['Email or Telegram line', 'Here is the link I use for everything: ' + url + ' (it always sends you to the right page).'],
|
||||
['Tracker-ready link', url + '?clickid={clickid}&s1={source} (replace the braces with your network\'s macros)'],
|
||||
['Sub-id split test', url + '?s1=email-A and ' + url + '?s1=email-B (each shows up under Sources)'],
|
||||
]);
|
||||
$('shareKit').innerHTML = kit.map(([t, body], i) => '<div class="panel" style="padding:10px 12px"><div style="display:flex;justify-content:space-between;align-items:center;gap:8px"><b>' + esc(t) + '</b><button class="btn sm" type="button" data-cp="' + i + '">Copy</button></div><div class="mono muted" style="font-size:12px;overflow-wrap:anywhere;margin-top:6px" id="kit-' + i + '">' + esc(body) + '</div></div>').join('');
|
||||
const picker = '<div class="panel" style="padding:10px 12px"><div style="display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:end"><label class="lbl" style="margin:0">Traffic source for this link<select class="field" id="srcSel"><option value="">None (generic tracker macros)</option>' + SRC.map(s => '<option value="' + s.id + '"' + (s.id === r.sourceId ? ' selected' : '') + '>' + esc(s.name) + (s.site ? ' · ' + esc(s.site) : '') + '</option>').join('') + '</select></label><a class="btn sm" href="/sources">Manage sources</a></div>'
|
||||
+ '<div class="muted" style="font-size:11.5px;margin-top:6px">' + (src ? 'Paste the campaign URL below as the destination in ' + esc(src.site || src.name) + '. Conversions from this link fire ' + esc(src.name) + '\'s postback' + (src.postbackUrl ? '' : ' once one is set under Sources') + '.' : 'A source fills in the network\'s macros for you and tells that network when a click converts. Pick one, or make one under Sources.') + '</div></div>';
|
||||
$('shareKit').innerHTML = picker + kit.map(([t, body], i) => '<div class="panel" style="padding:10px 12px"><div style="display:flex;justify-content:space-between;align-items:center;gap:8px"><b>' + esc(t) + '</b><button class="btn sm" type="button" data-cp="' + i + '">Copy</button></div><div class="mono muted" style="font-size:12px;overflow-wrap:anywhere;margin-top:6px" id="kit-' + i + '">' + esc(body) + '</div></div>').join('');
|
||||
$('shareKit').querySelectorAll('[data-cp]').forEach(b => b.addEventListener('click', () => CR.copy($('kit-' + b.dataset.cp).textContent)));
|
||||
$('srcSel').addEventListener('change', async () => { try { await api('/api/my/rotations/' + r.id, { sourceId: $('srcSel').value }); toast($('srcSel').value ? 'Source saved' : 'Source removed'); load(true); } catch (e) { toast(e.message, true); } });
|
||||
}
|
||||
// the rotation's own hours editor on the Hours tab. Not redrawn while the member is mid-edit (the 60 s refresh would eat their taps).
|
||||
let RH = null; // { rid, dirty }
|
||||
|
||||
Reference in New Issue
Block a user