bd6d46003f
Landing with ?v=<hook> now sets attribution source "angle:<hook>" (explicit utm/src still wins), so the existing admin funnel table shows views -> join clicks -> purchases per angle with no new UI. Each curiosity-video card on /tools gains a paste-ready description block ending in the matched invite link - aligning with the "link in the description" line baked into every recording.
26 lines
1.3 KiB
JavaScript
26 lines
1.3 KiB
JavaScript
(function(){
|
|
function getSource(){
|
|
try{
|
|
let s=sessionStorage.getItem('ctb.src');
|
|
if(s)return s;
|
|
const p=new URLSearchParams(location.search);
|
|
s=p.get('utm_source')||p.get('src')||'';
|
|
if(!s){const v=p.get('v');if(v&&/^[a-z]{2,12}$/.test(v))s='angle:'+v;}
|
|
if(!s&&document.referrer){try{const h=new URL(document.referrer).hostname;if(h&&h!==location.hostname)s=h}catch(e){}}
|
|
s=s||'(direct)';
|
|
sessionStorage.setItem('ctb.src',s);
|
|
return s;
|
|
}catch(e){return '(direct)'}
|
|
}
|
|
window.ctbGetSource=getSource;
|
|
try{
|
|
const p2=new URLSearchParams(location.search);
|
|
const cid=p2.get('clickid')||p2.get('cid');
|
|
if(cid&&!sessionStorage.getItem('ctb.clickid'))sessionStorage.setItem('ctb.clickid',cid.slice(0,80));
|
|
}catch(e){}
|
|
window.ctbGetClickId=function(){try{return sessionStorage.getItem('ctb.clickid')||''}catch(e){return ''}};
|
|
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(()=>{});
|
|
})();
|