Official WordPress plugin for Betterlytics - privacy-first, open source analytics.
- Automatic Script Injection - Adds the lightweight (<1KB) Betterlytics tracking script to your site
- Modern Admin UI - Immersive, fast admin interface built with Tailwind CSS v4
- WordPress Hooks Integration - Map WordPress actions to Betterlytics custom events
- Download the plugin and upload to
/wp-content/plugins/betterlytics/ - Activate the plugin through the 'Plugins' menu in WordPress
- Go to Settings > Betterlytics to configure
| Setting | Description |
|---|---|
| Enable Tracking | Toggle tracking on/off |
| Site ID | Your unique Site ID from the Betterlytics dashboard |
Need to configure the plugin via deployment pipelines, WP-CLI, or infrastructure-as-code? See CONFIGURATION.md for WP-CLI commands, environment variables, Ansible playbooks, and more.
You can send custom events from your theme or plugin:
// Queue an event to be sent on page load
add_action( 'wp_footer', function() {
if ( ! Betterlytics_Options::is_tracking_enabled() ) {
return;
}
?>
<script>
betterlytics.event('custom-event', {
category: 'engagement',
value: 123
});
</script>
<?php
});if ( Betterlytics_Options::is_tracking_enabled() ) {
// Tracking is active
}$options = Betterlytics_Options::get_options();
// Returns: site_id, server_url, script_url, enabled, track_outbound, etc.
// Get a single option
$site_id = Betterlytics_Options::get( 'site_id' );- WordPress 5.0+
- PHP 7.4+
- pnpm 9.0+ (for developers)
GPL v2 or later
Contributions are welcome! See CONTRIBUTING.md for development setup, testing instructions, and guidelines.