analyze_posthog
This module is part of the Analyze module ecosystem and included in DXPR CMS.
Your Analytics Data Belongs Next to Your Content, Not in Another Tab
You're editing a page. How many visitors did it get this month? Is traffic growing or declining? Which countries and devices are your audience using? Right now you'd switch to PostHog, find the URL, set the date range, and read a dashboard. With this module, that data is right there on the Analyze tab — every entity, every metric, zero context switching.
You need Analyze PostHog if
- You use PostHog for product analytics (cloud or self-hosted) and want to see traffic data per page inside Drupal
- Your content team needs pageview, visitor, and session counts without leaving the CMS
- You want to compare this period to the previous one and spot trends at a glance — not just static numbers
- You need to break down traffic by referrer, country, device, or browser for targeted content decisions
How It Works
Install the module, store your PostHog API key using the Key module, enter your PostHog host and project ID in the settings, and you're connected. Every content entity with a URL path gets analytics data in its Analyze tab — pulled live from PostHog's HogQL API. A sitewide report surfaces traffic patterns across your entire site.
What You Get
-
Pageviews, visitors, sessions, and bounce rate per page
Every content entity shows its PostHog performance in the Analyze tab — with change vs the previous period (e.g., "397 pageviews (+12.3%)") so you see trends, not just numbers.
-
Dimension breakdowns
Drill into the full report to see where your traffic comes from and how it behaves:
- Referrer — which sites and campaigns send visitors to this page
- Country — geographic distribution of your audience
- Device — desktop vs mobile vs tablet breakdown
- Browser — Chrome, Firefox, Safari, and others
- Page — top pages across your site (sitewide report)
-
Sitewide and entity-level reports
The sitewide report at /admin/reports/posthog shows KPIs and dimension tables for your entire site. Entity reports show the same data scoped to a single page. Both include previous period comparison.
-
Filters for focused analysis
Filter reports by country, status (new, up, down, lost), and text search to zero in on the data that matters. Filters work on both sitewide and entity reports.
-
Session replay link
Jump directly from the Analyze tab to PostHog's session replay — pre-filtered to the current page — and watch real users interact with your content.
-
Conversion attribution (coming soon)
Connect page visits to business outcomes. Define conversion goals (signups, purchases, form submissions) and see which pages drive the most conversions — using PostHog's session-based attribution.
-
Drush commands
Query analytics for any URL, view sitewide reports, check connection status, and clear the cache from the command line — useful for scripted reporting, CI pipelines, and DevOps workflows.
Getting Started
- Install with Composer:
composer require drupal/analyze_posthog - Enable the module and the Key module
- Create a PostHog personal API key with read access
- Store the API key at /admin/config/system/keys (Key module) and configure your PostHog host and project ID at /admin/config/analyze/posthog
- Enable the analyzer per content type at /admin/config/content/analyze-settings
Prefer a turnkey demo site?
Spin up DXPR CMS — Drupal pre-configured with DXPR Builder, DXPR Theme, the full Analyze suite including PostHog integration, and security best practices out of the box.
Additional requirements
This module requires: