Analytics Integration for PostHog, WP, & WC
Integrate PostHog with WordPress and WooCommerce for detailed user behavior tracking, product analytics, experimentation, and more.
Install in
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
Written by Joobi from the project's own listing. See the source page
1.5.5
- Fix: Link Prefixes saved with blank lines or Windows line endings no longer track every link click or stop link tracking; the list is cleaned on save and when loaded
- Link tracking script ignores empty prefixes
1.5.4
- Tested with WordPress 7.2 and PHP 8.5; checked for PHP 8.6 deprecations
- Use wp.editor.PluginSidebar for the experiment sidebar (wp.editPost.PluginSidebar is deprecated) and declare all editor script dependencies
- Opt the experiment sidebar controls into the current @wordpress/components sizing and margin styles
- Do not load the experiment editor script in the widgets and Customizer editors (avoids the core wp-editor notice)
- Replace deprecated jQuery shorthand calls in the admin and WooCommerce scripts
- Keep line breaks when saving link prefixes, so each prefix on its own line is tracked
- Add a plugin version constant
1.5.3
- Fix custom block attribute registration
1.5.2
- Refactor custom initialization settings
- Add boolean value conversion helper
1.5.1
- Use form for script customization to avoid arbitrary script injection
1.5.0
- Add nonce verification for AJAX
- Proper escaping
- json_encode to wp_json_encode
- Rename classes, functions, prefixes
- Refactor all scripts as dedicated .js files and enqueue them
1.4.11
- Set default tracking mode to identified_only
- Properly debug-gated all console logging
1.4.10
- Fixed JavaScript syntax error in WooCommerce integration
1.4.9
- Fixed jQuery selector in toggleSettings
1.4.8
- Improved compatibility with WooCommerce
- Fixed issue with direct add-to-cart link tracking
- Enhanced checkout process tracking
1.4.7
- Added support for custom PostHog instance
- Improved WooCommerce checkout tracking
- Fixed JavaScript errors
1.4.6
- Added link click tracking features
- Improved PostHog feature flag experiment functionality
- Fixed compatibility issues with WordPress 6.7
1.4.5
- Added custom initialization options
- Improved error handling and debugging
- Fixed issue with duplicate events
1.4.0
- Added support for Gutenberg experiments
- Enhanced WooCommerce integration
- Improved user identification
1.3.0
- Added WooCommerce checkout tracking
- Improved cart event handling
- Fixed issues with event batching
1.2.0
- Added product view tracking
- Enhanced add-to-cart event data
- Fixed compatibility issues with other plugins
1.1.0
- Added basic WooCommerce support
- Improved user tracking
1.0.0
- Initial release with core PostHog integration
Follow this listing's changes (Atom feed)