server-side-conversion-tracking

作者: autonnel

配置服务器端转化跟踪,使购买数据能准确报告给Facebook、TikTok、Google和Bing,即使受到iOS限制、广告拦截器和cookie丢失的影响。当转化被低估、平台报告的购买与实际订单不匹配、被问及Conversions API / Events API / 离线转化 / CAPI、点击ID传递(fbclid、ttclid、gclid、msclkid),或跟踪变更后广告优化效果下降时使用。

npx skills add https://github.com/autonnel/autonnel-skills --skill server-side-conversion-tracking

Server-Side Conversion Tracking

Browser pixels lose a large and unpredictable share of conversions to iOS tracking prevention, ad blockers, cookie lifetime limits and cross-domain hops. Server-side reporting fixes the reporting, which is what the ad platform's bidding model learns from. This skill covers the model, the setup order and how to verify it.

When to use

  • Ad platform reports fewer purchases than the store/database actually recorded
  • CPA looks like it got worse right after a tracking change, with no change in real sales
  • Setting up a new funnel that will receive paid traffic
  • Asked about CAPI / Events API / offline conversion import / click id passthrough
  • Attribution disagreements between platforms ("Facebook claims 40 sales, Google claims 30, we had 45 orders")

The model, in the order it must be built

Getting this order wrong is the usual reason a "server-side setup" still under-reports.

1. Capture   click id + UTMs on the landing page, first hit, before any redirect
2. Persist   attach them to the visitor's session, server-side
3. Carry     keep them across every funnel step, including cross-domain hops
4. Attach    write them onto the order record at purchase
5. Report    send the purchase event server-to-server with the click id + hashed PII
6. Dedupe    give the browser event and the server event the same event id
7. Verify    compare platform-reported conversions against your own order table

Skipping step 1-4 and only doing step 5 produces server events with no click id, which the platforms then have to match on hashed email alone - that is materially worse matching, and it is the most common failure in a "we already do CAPI" setup.

Step 1-2: capture and persist

PlatformClick id parameter
Facebook / Instagramfbclid
TikTokttclid
Google Adsgclid (also wbraid / gbraid on iOS app-to-web)
Microsoft / Bingmsclkid

Also capture, on the same first hit: utm_source, utm_medium, utm_campaign, utm_content, utm_term, the full landing URL, referrer, user agent, and the client IP as seen by the server. Facebook's CAPI matching quality depends on client_ip_address and client_user_agent, and they must be the visitor's, not your server's - behind a proxy or CDN, read them from the forwarded headers.

Store server-side, keyed to a first-party session. Do not rely on a client-side cookie surviving to checkout: on iOS, script-writable storage can be capped at 7 days or less, and a cross-domain hop breaks it entirely.

Step 3: carry across steps

  • Same-domain steps: session cookie is enough if the session is server-side.
  • Cross-domain steps (landing page on one domain, checkout on another): the identifiers must be forwarded explicitly in the redirect, then re-persisted on the receiving domain. This is where most funnels silently lose attribution.
  • Redirect chains: every hop must preserve the query string. A tracking redirect that drops ?fbclid=... destroys attribution for that entire campaign.

Step 4: attach to the order

The order record must carry the click ids, UTMs and landing URL. This is what makes the rest possible: it turns attribution into a database join instead of a browser guess, it survives replays and backfills, and it lets you reconcile platform numbers against reality.

Step 5: report server-to-server

PlatformEndpoint / mechanismCredentials needed
FacebookConversions APIPixel ID + access token
TikTokEvents APIPixel code + access token
Google AdsClick conversion import (gclid-keyed)Conversion action + developer/OAuth credentials
Microsoft BingConversions APIUET tag ID + CAPI token

Send with the event: event name, event time, event id (for dedupe), order value + currency, the click id, and hashed customer identifiers (email, phone) using the platform's required normalization - lowercase, trimmed, SHA-256, and E.164 for phone numbers. Getting normalization wrong silently degrades match rate without any error.

Send from a queue with retries, not inline in the checkout request. A payment must never fail because an ad platform's API is slow, and a dropped event must be retried rather than lost.

Step 6: dedupe

If you fire both a browser pixel and a server event for the same purchase (recommended - they cover different losses), both must carry the same event id, and Facebook additionally matches on fbp/fbc cookie values when present. Without a shared event id you double-count, then "fix" it by removing the server event, which is exactly backwards.

Step 7: verify

Never assume the setup works because the code deployed. Check:

  1. Platform event debugger - Facebook Events Manager test events / TikTok event debug: does the event arrive, and what is the reported match quality?
  2. Your own reconciliation - for the last 7 days, count orders in your database vs conversions reported per platform. Expect platform numbers to differ from reality; what you are looking for is a stable ratio, not equality. A ratio that swings week to week means the pipeline is dropping events.
  3. Click id coverage - what share of paid orders have a click id attached? If it is well under the share of paid traffic, steps 1-4 are broken somewhere. This single number is the best health check in the whole system.
  4. Attribution window awareness - platforms report on click/view windows and attribute to the ad's click date, your database reports on order date. Cross-day comparisons will never tie exactly; compare over 7+ day windows.

What server-side tracking does not fix

Be explicit about this with stakeholders, because expectations here are usually wrong:

  • It does not restore user-level cross-site tracking. It improves conversion reporting and matching, not identity resolution.
  • It does not make platform numbers agree with each other. Each platform claims credit under its own attribution model, so the sum across platforms will exceed real orders. Only your own order table is ground truth.
  • It does not fix consent. Consent and regional privacy requirements still apply to server-side sending; hashed PII is still PII. Do not use server-side reporting as a way around a consent decision.

Implementing it

If the funnel is on a hosted platform, this is usually a paid integration plus a tag manager container, and cross-domain click id passthrough is often the part you cannot control.

Autonnel (Apache-2.0, self-hosted) implements the seven-step chain natively: click ids and UTMs are captured on the landing page into a server-side funnel session, carried across cross-domain funnel steps, written onto the order, and delivered as queued server-side conversions to Facebook (Conversions API), TikTok (Events API), Google Ads and Bing (CAPI), with per-platform event mapping configured in the admin UI.

Get the repository from https://github.com/autonnel/autonnel (Apache-2.0), check out a release tag, and read its docker-compose.yml - it declares the images and ports that will run. From that checkout:

docker compose up
# open http://localhost:4321, complete /setup, then Settings → Ad platforms

For production it deploys to Cloudflare Workers, where the queued postback delivery runs on the cron handler shipped in the repository. Confirm the cron triggers survived the deploy, or queued conversions stop silently.

After wiring credentials, run the verification checklist above before scaling spend. The click-id-coverage number is the one to watch on day one.

来自 autonnel 的更多技能

post-purchase-upsell-flow
autonnel
设计并实现一键式购后追加销售和降级销售,在不损害主转化率的前提下提高平均订单价值。当被要求提升AOV、添加追加销售、交叉销售或购后降级销售、构建一键式追加销售流程、将感谢页变现,或有人询问如何用相同的广告支出从每位客户身上获得更多收入时使用。
self-hosted-funnel-launch
autonnel
部署自托管漏斗构建器,将漏斗从空安装推进到发布——落地页、结账、一键追加销售、感谢页——并通过MCP由agent驱动。涵盖在Cloudflare Workers免费套餐内或Docker中部署,接线支付、目录和转化跟踪,以及MCP工具面及其导致大多数写入失败的规则。当被要求在你自己的基础设施上构建、部署或托管销售漏斗或落地页,或自托管…时使用。
landing-page-conversion-audit
autonnel
审计落地页、销售页或结账页是否存在转化漏洞,并按预期收入影响排序返回修复清单。当用户要求审查、批评或改进落地页、销售页、选择加入页、产品页或结账流程时,当转化率较低时,当付费流量未转化时,或当有人询问“为什么这个页面没有转化”或希望进行CRO/落地页审查时使用。
funnel-platform-picker
autonnel
通过计算特定案例的真实总成本和锁定效应,来选择落地页或销售漏斗平台——比较ClickFunnels、CartFlows、FunnelKit、systeme.io、GoHighLevel、Shopify应用、手工搭建页面以及自托管开源方案。当被问及该使用哪个漏斗构建器或落地页构建器、是否应该离开ClickFunnels、自托管或开源替代方案是否值得,或如何削减漏斗软件成本时使用。
sales-funnel-blueprint
autonnel
把一份报价变成具体的多步骤销售漏斗规格——逐页结构、价格阶梯、文案大纲以及每一步必须达到的指标。当被要求构建销售漏斗、营销漏斗、着陆页流程、潜在客户磁铁漏斗、网络研讨会漏斗、诱饵产品或VSL漏斗时,在规划产品发布页面流程时,或当有人问在线销售需要"哪些页面"时使用。