Using PostHog and TrackStack together
PostHog answers product questions; TrackStack delivers conversions to ad platforms. Here is how to run both without duplicate scripts, conflicting proxies, or split event schemas.
- PostHog
- integrations
- proxy
- analytics
Problem: Product uses PostHog for funnels and session replay. Marketing needs Meta and Google conversion data. You do not want two SDKs, two proxies, and two event naming conventions in the same Next.js app.
Different jobs
PostHog is product analytics: feature adoption, retention cohorts, session replay. TrackStack is conversion infrastructure: deliver SignUp and Purchase to ad platform CAPIs with delivery logs and retries.
They overlap on capture but diverge on destinations. PostHog does not send hashed PII to Meta. TrackStack does not replace PostHog's product UI.
Single proxy setup
TrackStack can proxy PostHog through a first-party path like /_ph via withTrackStack in next.config.ts. One proxy serves PostHog ingest and TrackStack edge events.
See Integrations for configuration options.
export const trackstack = createTrackStack({
publicKey: process.env.NEXT_PUBLIC_TRACKSTACK_KEY!,
posthog: {
key: process.env.NEXT_PUBLIC_POSTHOG_KEY!,
host: "/_ph",
},
});Event naming discipline
Keep PostHog events descriptive for product (feature_export_clicked). Keep TrackStack events canonical for ads (SignUp, Purchase, StartTrial).
Do not mirror every PostHog event to ad platforms — noise hurts optimization.
posthog.capture("onboarding_step_completed", { step: 2 });
trackstack.capture("SignUp", {
email: user.email,
eventId: `signup_${user.id}`,
});Dashboard configuration
Connect PostHog as a source in Settings → Integrations if you want webhook forwarding. For most teams, client-side dual capture with shared proxy is simpler.
Use PostHog for product debugging. Use delivery logs for ad HTTP responses.
Future docs
A dedicated /docs/integrations/posthog page is on the content backlog — until then, start from quickstart plus the proxy config above.
Sources
Official documentation and references cited in this article.
More in Product
Domain allowlisting for public API keys
TrackStack public keys ship in client bundles. Domain allowlisting restricts which origins can send events — a basic security control every production app should configure.
Read postDelivery logs: debug CAPI like you debug API requests
Every conversion should leave an HTTP trail. Delivery logs show platform responses, payloads, and retries — so you fix match issues before wasting ad spend.
Read postConfigure: map canonical events to ad platforms
The Configure split separates credentials, per-platform event allowlists, and checklists from generic settings — so you ship destinations without tag manager indirection.
Read postReady to fix your conversion pipeline?
Install the TrackStack SDK, route events to Meta and Google, and verify delivery from one dashboard.