feat: add Meta Pixel to docs site#890
Open
dhananjay6561 wants to merge 4 commits into
Open
Conversation
Signed-off-by: dhananjay6561 <dhananjayaggarwal6561@gmail.com>
Signed-off-by: dhananjay6561 <dhananjayaggarwal6561@gmail.com>
Signed-off-by: dhananjay6561 <dhananjayaggarwal6561@gmail.com>
amaan-bhati
reviewed
Jul 14, 2026
amaan-bhati
left a comment
Member
There was a problem hiding this comment.
Build not verified locally
The PR description calls out that a full Docusaurus build was not run due to disk space. Worth someone on the team doing a quick npm run build on this branch before merging, or at minimum checking the Network tab for the tr?...ev=PageView beacon after the preview deploy lands.
…t pixel Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
amaan-bhati
self-requested a review
July 14, 2026 10:44
Member
Author
|
cc: @nehagup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Installs the Meta (Facebook) Pixel (
2006330080011702) site-wide on the docs.<head>on every page viaheadTags(docusaurus.config.js): loadsfbevents.js, runsfbq('init', ...), and fires the initialPageView.fbqis defined synchronously by the snippet, so the firstPageViewcan never race the loader.src/metaPixelRouteTracker.js, registered as aclientModule): re-firesPageViewon client-side navigation via Docusaurus'sonRouteDidUpdatelifecycle hook. Docusaurus is a single-page app, so without this the base snippet would only ever report the first page a visitor lands on.<noscript>tracking-pixel fallback for JS-disabled clients.Events tracked
PageViewonly.ViewContent,Lead,CompleteRegistration, custom, etc.) are tracked in this PR. Those can be added later on specific CTAs/flows.When does the event fire?
The first PageView is fired synchronously by the base script (where
fbqis guaranteed defined), and subsequent PageViews are fired by the client module on route changes. This split avoids both an fbq-not-ready race on the first load and double-counting the initial page.<head>snippet runsfbq('init')+fbq('track','PageView')onRouteDidUpdateruns on first renderpreviousLocationisnull→ guard skips itlocation.pathnamediffers frompreviousLocation.pathname→ firesfbq('track','PageView')fbevents.jsblocked (the<noscript><img>covers the JS-off case with a single beacon)How the pixel leads to an ad (flow)
flowchart TD A[User opens keploy.io/docs] --> B[Meta Pixel runs on page load<br/>fbq init + PageView] B --> C[Browser sends beacon to Meta<br/>facebook.com/tr + Facebook cookies] C --> D[Meta identifies the visitor via cookie<br/>Facebook account XYZ] D --> E[Meta adds the user to Keploy's audience] E --> F[Later the user scrolls Instagram / Facebook] F --> G[Meta serves the user a Keploy ad]The site never sends personal data — it only says "a PageView happened." Identity is matched on Meta's side via the Facebook cookies the browser attaches to the
/trrequest. This depends on third-party cookies, so it's weaker/absent for logged-out users, Safari/Firefox, private mode, and ad blockers (a future Conversions API would recover some of that).How to test (for reviewers)
yarn start, then openhttp://localhost:3000/docs/.facebookin the filter bar.fbevents.js→200(notblocked:other/ 0 kB)tr/?id=2006330080011702&ev=PageView→200tr/?...ev=PageViewbeacon appears → PageView count goes 1 → 2.2006330080011702and browse the local site to watch the same PageViews land on Meta's side.Pass criteria: 1 PageView on load, +1 per SPA path change, 0 on same-path clicks — all beacons
200.Verify (author)
yarn buildlocally; compiles clean and the generated static HTML contains the pixel (fbq("init","2006330080011702"),fbq("track","PageView"), theconnect.facebook.net/en_US/fbevents.jsloader, and the<noscript>beacon).onRouteDidUpdateguard reviewed: fires only on an actualpathnamechange, skips the initial load (previousLocation === null) and same-path updates — so no double-count on landing and one PageView per SPA navigation.docusaurus.config.jsandsrc/metaPixelRouteTracker.js.Note on the hardcoded pixel ID
The pixel ID is inlined, matching every other tracker in this repo — Microsoft Clarity (
static/scripts/clarity.js), Apollo (apollo-init.js), and Google Analytics/gtag (docusaurus.config.js) are all hardcoded, and the repo has no.envfiles orprocess.envusage to read from. The preview/staging-pollution concern is valid but applies equally to those existing trackers, so moving all of them behind env config (with preview/staging skipped) is proposed as a dedicated repo-wide follow-up rather than gating the pixel alone here.Docs deploys separately from the landing page (keploy/landing#245 adds the same snippet there) — this PR gives the docs site the equivalent coverage.