$ man how-to/posthog-for-gtm
CLI Toolsintermediate
PostHog for GTM Engineers
Open-source analytics with more precision than GA or HubSpot for ABM tracking
Why PostHog for GTM
Google Analytics tells you "50 people visited your pricing page." PostHog tells you "3 people from Acme Corp visited your /for/acme landing page, read 80% of the case study section, clicked the ROI calculator twice, and left without booking. One came back the next day from a LinkedIn ad."
That level of detail changes how you run ABM. You stop guessing which accounts are engaged and start knowing. PostHog is event-based. Every interaction is a structured event with properties. You define what matters and PostHog captures it with full context.
The open-source angle matters too. Your analytics data stays yours. No vendor lock-in. Self-host if data sovereignty is a requirement. The cloud version is free up to 1 million events per month, which covers most GTM operations.
PATTERN
ABM Event Architecture
Define events that map to your ABM funnel stages:
abm_page_view - someone hits a personalized landing page. Properties: company slug, referral source, UTM parameters.
abm_section_read - scroll depth on key sections. Properties: section name, time spent, percentage viewed.
abm_cta_click - any call-to-action interaction. Properties: CTA type (book demo, download, contact), page location.
abm_form_submit - form completions. Properties: form type, company, lead score at time of submission.
With these four events, you build a complete ABM engagement funnel. Filter by company. Filter by time period. See exactly which accounts are warming up and which went cold.
PRO TIP
Claude Code + PostHog MCP
The PostHog MCP connects Claude Code directly to your analytics instance. This means natural language queries against your data.
"Show me which companies visited our ABM landing pages this week" - Claude queries PostHog, aggregates by company slug, returns a ranked list.
"Build a funnel from abm_page_view to abm_cta_click to abm_form_submit" - Claude creates the funnel in PostHog and returns conversion rates at each stage.
"Which landing page sections get the most engagement?" - Claude queries scroll depth events, groups by section, and ranks by average time spent.
No SQL. No dashboard builder. Describe the question, get the answer. This is the natural language analytics layer that makes PostHog accessible to GTM engineers who are not data analysts.
CODE
Setup in 15 Minutes
Step 1: Create a PostHog account at posthog.com. Free tier covers 1M events/month.
Step 2: Add the PostHog snippet to your site. For Next.js, use the posthog-js package. Initialize in your app layout with your project API key.
Step 3: Define custom events. In your ABM landing page components, add posthog.capture("abm_page_view", { company: slug, source: utm_source }). Do the same for scroll depth, CTA clicks, and form submissions.
Step 4: Connect PostHog MCP to Claude Code. Add the PostHog MCP server configuration with your API key. Test with "list my recent PostHog events."
Step 5: Build your first dashboard. Tell Claude Code "create a PostHog dashboard showing ABM landing page visits by company this month." It builds the dashboard through the MCP. Done.
related guides
related on other sites