
Analytics Integration for PostHog, WP, & WC
by Constantin Oesterling on WordPress.org
Integrate PostHog with WordPress and WooCommerce for detailed user behavior tracking, product analytics, experimentation, and more.
This (unofficial) PostHog plugin offers visitor and user tracking for WordPress and WooCommerce websites, leveraging PostHog’s powerful analytics platform.
Features
- Easy Setup: Configure with just your PostHog project ID
- WooCommerce Integration: Track ecommerce events including:
- Product views
- Add-to-cart actions
- Cart updates
- Checkout process
- Completed orders
- User Tracking: Capture and identify logged-in user data
- Link Click Tracking: Monitor clicks on links (affiliate links, etc.)
- PostHog Experiment Support (experimental): Run A/B tests and feature flag experiments using Gutenberg blocks
- Custom Initialization: Advanced options for custom PostHog configurations
Why Use PostHog?
PostHog is an all-in-one platform that helps you build better products. It includes all the tools you need to deploy changes, observe their effect, gather feedback, and iterate from there — and it’s completely free to get started.
Some of the features PostHog offers include…
- Product and web analytics
- Revenue tracking and surveys
- Session recording and heatmaps
- LLM observability and AI assistant
- Feature flags and experimentation
- Error tracking and issue assignment
- Data pipelines and integrations
You can create a free account with PostHog at posthog.com
WooCommerce Features
With WooCommerce enabled, the plugin automatically tracks:
- Product view events
- Add to cart actions
- Cart views and updates
- Checkout progress and completion
- Purchase events with detailed product information
Gutenberg Experiment Support
Create and manage PostHog experiments directly in the Gutenberg editor. Test different content variations using PostHog feature flags without any coding.
Link Click Tracking
Monitor link clicks with customizable link prefixes, supporting both direct links and encoded/obfuscated links.
Configuration
Basic Configuration
- Project ID: Your PostHog project ID (required)
- API Host: Select US or EU PostHog instance, or enter a custom URL
- Tracking Mode: Choose between tracking all visitors or only identified users
Advanced Options
- Debug Mode: Enable console logging for troubleshooting
- Gutenberg Experiments: Enable PostHog feature flag experiments in the Gutenberg editor
- Link Click Tracking: Track clicks on links with customizable prefixes
- Custom Mode: Override default initialization with custom PostHog script