← Dashboard

Pass _fbc / _fbp through SubId

Why pass the original _fbc?

When a user clicks a Facebook ad, the FB Pixel sets a _fbc cookie shaped fb.1.<click_time_ms>.<fbclid> plus _fbp for browser fingerprinting. Meta CAPI matches the conversion back to the ORIGINAL click using both that timestamp and the fbclid. If you only pass fbclid and rebuild _fbc with Date.now() at conversion time (hours/days later), attribution breaks. Fix: capture _fbc + _fbp on the landing page, stuff them into the affiliate SubId, and pass them back to Meta when the network postbacks.

SubId format

{fbc_or_fbclid}_{ttclid}_{gclid}_{fbp}
  • 1
    fbc (best) — cookie _fbc. If absent, use raw fbclid — the server reconstructs fbc using the click time.
  • 2
    ttclid — TikTok click id
  • 3
    gclid — Google click id
  • 4
    fbpthe _fbp cookie (recommended for better Meta match rate)

Separated by _. Leave empty by using two consecutive underscores (e.g. abc__xyz).

Cookie capture snippet

Drop into your landing page (after the Facebook Pixel base code). It reads _fbc/_fbp + ttclid + gclid and appends them to your affiliate links.

// Đặt trên landing page TRƯỚC khi user click affiliate link
function getCookie(n){return document.cookie.split('; ').find(r=>r.startsWith(n+'='))?.split('=')[1]||''}
function buildSubId(){
  const fbc = decodeURIComponent(getCookie('_fbc')); // fb.1.<ts>.<fbclid>
  const fbp = decodeURIComponent(getCookie('_fbp')); // fb.1.<ts>.<rand>
  const url = new URL(location.href);
  const ttclid = url.searchParams.get('ttclid') || '';
  const gclid  = url.searchParams.get('gclid')  || '';
  // Nếu chưa có _fbc, dựng tạm từ ?fbclid=
  const fbclid = url.searchParams.get('fbclid') || '';
  const fb = fbc || fbclid;
  return [fb, ttclid, gclid, fbp].join('_');
}
// Gắn vào mọi link affiliate
document.querySelectorAll('a[data-aff]').forEach(a=>{
  const u = new URL(a.href);
  u.searchParams.set('subid', buildSubId()); // hoặc 'sub_id', 'subid1'... tuỳ network
  a.href = u.toString();
});

Example — Impact

Affiliate link with full SubId1:

https://goto.network.com/abc123?subid1=fb.1.1733000000000.AbCdEf123__OXyz789_fb.1.1733000000000.987654321

The postback URL in your Dashboard automatically maps SubId1 → SubId2 → SubId3 and parses fbc/fbp out.

Example — PartnerStack

PartnerStack uses sub_ids[]. Pass the joined SubId as the first element:

https://app.partnerstack.com/refer/yourcompany?sub_ids[]=fb.1.1733000000000.AbCdEf123__OXyz789_fb.1.1733000000000.987654321

The first sub_ids element is used as the primary SubId.

Configuring the Facebook Ads URL

In Ads Manager, set the destination URL to YOUR landing page (not the affiliate link). The FB Pixel sets _fbc/_fbp there. The snippet above then attaches SubId when the user clicks through to the affiliate.

https://your-landing.com/promo?utm_source=fb&utm_campaign={{campaign.name}}

Don't use the affiliate link as the destination URL — FB Pixel can't set cookies cross-domain.

SubId validator

Paste the SubId you'll pass through the affiliate link to validate the format before running ads. Format: {fbc_or_fbclid}_{ttclid}_{gclid}_{fbp}

Common mistakes

  • URL-encoding _fbc turns dots into %2E — always decodeURIComponent when reading the cookie.
  • Missing fb or fbp in the right slot. Wrong slot = wrong click id type.
  • Using a separator other than _ (e.g. |). The parser only splits on _.
  • Using Date.now() to rebuild _fbc on the server — must use click time. The server handles this automatically when only fbclid is provided.