First-party retargeting: audiences (automatic 'My visitors' fed by pages + zones, custom pixel audiences via /p.js + /p.gif, ls.vid cookie + 24 h soft key), include/exclude audience targeting on banner/text/login campaigns, zone tag sends credentials with CORS echo, audience-targeted campaigns never syndicate, Audiences panel on Zones and selector on Ads
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -26,5 +26,21 @@
|
||||
const v = await dialog({ title: 'Add a zone', text: 'One zone per spot on a page. Paid ads only serve on the site you name here; anywhere else the tag shows the house banner.', fields: [{ k: 'name', label: 'Name', placeholder: 'My blog · sidebar', max: 60 }, { k: 'site', label: 'Site it lives on (required)', placeholder: 'myblog.com', max: 80 }, { k: 'size', label: 'Size: ' + (SIZES.join(', ') || '728x90, 468x60, 300x250, 160x600, 320x50'), value: '728x90', mono: true }], ok: 'Create' });
|
||||
if (!v) return; try { const r = await api('/api/my/zones', v); SEL = r.zone.id; toast('Zone created. Copy the tag.'); load(); } catch (e) { toast(e.message, true); }
|
||||
});
|
||||
CR.requireSession(load);
|
||||
// ---- audiences (first-party retargeting)
|
||||
const ptag = a => '<script async src="https://' + HOST + '/p.js" data-aud="' + a.id + '"></script>';
|
||||
async function loadAudiences() {
|
||||
let r; try { r = await CR.get('/api/my/audiences'); } catch (e) { return; }
|
||||
const A = r.audiences || []; HOST = r.host || HOST;
|
||||
$('audList').innerHTML = A.map(a => '<div style="padding:8px 0;border-top:1px solid var(--line)"><div style="display:flex;justify-content:space-between;gap:8px;align-items:center"><b>' + esc(a.name) + '</b>'
|
||||
+ '<span class="mono muted" style="font-size:11px">' + fmt(a.size30) + ' in 30 d · ' + fmt(a.size7) + ' in 7 d' + (a.soft ? ' · ' + fmt(a.soft) + ' without cookie (24 h)' : '') + '</span></div>'
|
||||
+ (a.auto ? '<div class="muted" style="font-size:11.5px">Automatic: your pages and your zones feed it. You can also paste its pixel elsewhere.</div>' : '')
|
||||
+ '<div class="code" style="display:block;font-size:10.5px;line-height:1.5;word-break:break-all;margin:6px 0">' + esc(ptag(a)) + '</div>'
|
||||
+ '<div style="display:flex;gap:6px;flex-wrap:wrap"><button class="btn sm" type="button" data-copy="' + a.id + '">Copy pixel</button>'
|
||||
+ (a.auto ? '' : '<button class="btn sm ghost" type="button" data-ren="' + a.id + '">Rename</button><button class="btn sm ghost danger" type="button" data-del="' + a.id + '">Remove</button>') + '</div></div>').join('');
|
||||
$('audList').querySelectorAll('[data-copy]').forEach(b => b.addEventListener('click', () => CR.copy(ptag(A.find(a => a.id === b.dataset.copy)))));
|
||||
$('audList').querySelectorAll('[data-ren]').forEach(b => b.addEventListener('click', async () => { const a = A.find(x => x.id === b.dataset.ren); const v = await dialog({ title: 'Rename audience', fields: [{ k: 'name', label: 'Name', value: a.name }], ok: 'Save' }); if (!v) return; try { await api('/api/my/audiences', { id: a.id, name: v.name }); toast('Renamed'); loadAudiences(); } catch (e) { toast(e.message, true); } }));
|
||||
$('audList').querySelectorAll('[data-del]').forEach(b => b.addEventListener('click', async () => { const a = A.find(x => x.id === b.dataset.del); if (!await dialog({ title: 'Remove ' + a.name + '?', text: 'Its visitor list is deleted. Campaigns that used it stop matching anyone.', ok: 'Remove', danger: true })) return; try { await api('/api/my/audiences', { id: a.id, remove: true }); toast('Removed'); loadAudiences(); } catch (e) { toast(e.message, true); } }));
|
||||
}
|
||||
$('audNew').addEventListener('click', async () => { const v = await dialog({ title: 'New audience', text: 'Name it after where the pixel will go, like "Blog readers" or "Checkout page".', fields: [{ k: 'name', label: 'Name', placeholder: 'Blog readers' }], ok: 'Create' }); if (!v) return; try { await api('/api/my/audiences', { name: v.name }); toast('Created. Paste its pixel on the site.'); loadAudiences(); } catch (e) { toast(e.message, true); } });
|
||||
CR.requireSession(() => { load(); loadAudiences(); });
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user