CTB featured-offer relay: 30s visible-dwell engaged event -> signed postback
track.js: on join pages with a ctb1_ clickid, count 30s of VISIBLE time (1s ticks, pauses when tab hidden), then report engaged once per session. server.js: relay engaged ctb1_ clickids to the CTB backend per the spec contract (X-Offer-Secret header, any-200-is-done); light in-process dedupe. New volume config keys ctbOfferPostbackUrl + ctbOfferSecret (PATCH allowlist). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,4 +22,22 @@
|
||||
const path=location.pathname.replace(/\/$/,'')||'/';
|
||||
const page=path==='/'?'bridge':(path==='/start'?'start':(path==='/training'?'training':(path==='/join-now'?'joinnow':(/^\/join\/\d+$/.test(path)?'join':null))));
|
||||
if(page)fetch('/api/public/track',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({event:page,source:getSource()})}).catch(()=>{});
|
||||
|
||||
// CTB Rewards featured offer: a ctb1_ clickid means this visitor earns
|
||||
// coins for a REAL look at the tour — count 30 seconds of visible time on
|
||||
// a join page, then report "engaged" once (server relays it to CTB).
|
||||
(function(){
|
||||
const cid=window.ctbGetClickId();
|
||||
if(!cid||cid.indexOf('ctb1_')!==0)return;
|
||||
if(page!=='join'&&page!=='joinnow')return;
|
||||
try{ if(sessionStorage.getItem('ctb.engaged')===cid)return; }catch(e){}
|
||||
let seen=0;
|
||||
const t=setInterval(function(){
|
||||
if(document.visibilityState!=='visible')return;
|
||||
if(++seen<30)return;
|
||||
clearInterval(t);
|
||||
try{ sessionStorage.setItem('ctb.engaged',cid); }catch(e){}
|
||||
fetch('/api/public/track',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({event:'engaged',source:getSource(),clickid:cid})}).catch(()=>{});
|
||||
},1000);
|
||||
})();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user