fbc-guard

v0.1.0
io.github.adsandcode/fbc-guard Checked 1 day ago Published 1 month ago

Static checks for Meta _fbc, _fbp and fbclid code that cause modified click ID warnings.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

check_fbc_code

Statically check HTML or JavaScript that reads `fbclid` from the URL and writes Meta's `_fbc` click ID cookie (and optionally `_fbp`). It catches the mistakes that make Meta Events Manager report a modified fbclid or attribute a conversion to the wrong ad: keeping an old click ID when a visitor arrives from a new ad, decoding, re-casing or truncating the click ID, writing creationTime in seconds instead of milliseconds, and hard-coding subdomainIndex. Rules: FBC-01: A new fbclid must overwrite an older _fbc cookie. FBC-02: Do not URL-decode fbclid a second time. FBC-03: Do not change the case…

ParameterTypeDescription
code *stringHTML or JavaScript source to check. Include every file that touches fbclid, _fbc or _fbp, concatenated.
kindstringHow to read `code`. "html": analyse the inline <script> bodies. "js": analyse it as JavaScript. "auto": HTML if it starts with "<", JavaScript otherwise.

check_fbc_url

Fetch a landing page and run the same checks as check_fbc_code on its HTML plus every same-origin <script src> it loads, so tracking code kept in an external file is included. Cross-origin scripts (tag managers, the Meta Pixel, analytics SDKs) are never fetched and are listed under skipped_scripts. Limits: 30 s timeout per request, at most 20 scripts, 2 MB per file. Uses a mobile Safari user agent. Only public hosts are fetched: URLs that resolve to loopback, private, link-local or other internal addresses are refused, on every redirect hop too (start the server with FBC_GUARD_ALLOW_PRIVATE=1…

ParameterTypeDescription
url *stringhttp or https URL of the landing page.