Description
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
Installation
- Upload the plugin files to the
/wp-content/plugins/posthog-wp
directory, or install the plugin through the WordPress plugins screen - Activate the plugin through the ‘Plugins’ screen in WordPress
- Navigate to Settings > PostHog Integration to configure the plugin
- Enter your PostHog Project ID (starts with ‘phc_’)
- Choose your PostHog instance (US, EU, or custom)
- Configure additional options as needed
FAQ
-
Where do I find my PostHog Project ID?
-
Log in to your PostHog account, navigate to Project Settings, and copy the Project API Key (starts with ‘phc_’).
-
Does this plugin work without WooCommerce?
-
Yes, the plugin works with standard WordPress sites for basic analytics. WooCommerce-specific tracking is only activated when WooCommerce is installed and active.
-
Can I use this with other PostHog instances besides the official ones?
-
Yes, you can use a custom API host URL for reverse proxy PostHog instances.
-
How do I set up an experiment?
-
- Enable Gutenberg experiments in the plugin settings
- Edit a post or page with the Gutenberg editor
- Select any block and use the PostHog Experiment panel in the block settings sidebar
- Enter your feature flag name and variant
- Save your post/page
-
Is this plugin GDPR compliant?
-
This plugin integrates with PostHog, which has GDPR compliance features. The plugin itself is designed to work with PostHog’s privacy controls. However, you are responsible for ensuring your specific implementation meets GDPR requirements, including proper consent management.
Reviews
There are no reviews for this plugin.
Contributors & Developers
“Analytics Integration for PostHog, WP, & WC” is open source software. The following people have contributed to this plugin.
ContributorsTranslate “Analytics Integration for PostHog, WP, & WC” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Changelog
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