Add Privacy-First Analytics to Your WordPress Site
WordPress powers 43% of the web. It also has a significant analytics problem: Google Analytics requires GDPR cookie consent, Jetpack bundles too much, and most WordPress analytics plugins are bloated or expensive.
Measure.events works on WordPress with a single script tag. No plugin required. No cookies. No consent banner. And an MCP server that lets your AI tools query your site data directly.
Setup: No Plugin Required
Method 1: Theme functions.php
Add this to your theme’s functions.php (or a child theme):
function add_measure_analytics() {
$site_key = 'YOUR_SITE_KEY'; // from your Measure.events dashboard
echo '<script
src="https://lets.measure.events/api/script/' . esc_attr($site_key) . '"
data-site="' . esc_attr($site_key) . '"
defer>
</script>';
}
add_action('wp_head', 'add_measure_analytics');
Method 2: WordPress Customizer
Go to Appearance → Customize → Additional CSS / Scripts (location varies by theme) and paste:
<script
src="https://lets.measure.events/api/script/YOUR_SITE_KEY"
data-site="YOUR_SITE_KEY"
defer
></script>
Method 3: Insert Headers and Footers Plugin
If you use the free Insert Headers and Footers plugin:
- Go to Settings → Insert Headers and Footers
- Paste the script tag in the Header section
- Save
WooCommerce Event Tracking
Track product views, add-to-cart, and purchases:
// Track product page views
function measure_track_product_view() {
if (is_product()) {
global $product;
?>
<script>
document.addEventListener('DOMContentLoaded', function() {
if (window.measure) {
window.measure('event', {
name: 'product_view',
props: {
product_id: '<?php echo esc_js($product->get_id()); ?>',
product_name: '<?php echo esc_js($product->get_name()); ?>',
price: '<?php echo esc_js($product->get_price()); ?>'
}
});
}
});
</script>
<?php
}
}
add_action('wp_footer', 'measure_track_product_view');
// Track add-to-cart
function measure_track_add_to_cart() {
?>
<script>
document.addEventListener('added_to_cart', function(e) {
if (window.measure) {
window.measure('event', { name: 'add_to_cart' });
}
});
</script>
<?php
}
add_action('wp_footer', 'measure_track_add_to_cart');
// Track purchases
function measure_track_purchase($order_id) {
$order = wc_get_order($order_id);
if (!$order) return;
?>
<script>
if (window.measure) {
window.measure('event', {
name: 'purchase',
props: {
value: '<?php echo esc_js($order->get_total()); ?>',
currency: '<?php echo esc_js($order->get_currency()); ?>'
}
});
}
</script>
<?php
}
add_action('woocommerce_thankyou', 'measure_track_purchase');
Contact Form 7 Tracking
function measure_track_cf7_submit() {
?>
<script>
document.addEventListener('wpcf7mailsent', function(e) {
if (window.measure) {
window.measure('event', {
name: 'form_submit',
props: { form_id: e.detail.unitId }
});
}
});
</script>
<?php
}
add_action('wp_footer', 'measure_track_cf7_submit');
Elementor Form Tracking
function measure_track_elementor_forms() {
?>
<script>
document.addEventListener('DOMContentLoaded', function() {
if (window.elementorProFrontend) {
elementorProFrontend.hooks.addAction(
'elementor_pro/forms/submit_success',
function(scope, data) {
if (window.measure) {
window.measure('event', {
name: 'form_submit',
props: { form_name: data.id }
});
}
}
);
}
});
</script>
<?php
}
add_action('wp_footer', 'measure_track_elementor_forms');
Excluding Admin Traffic
Avoid tracking your own visits:
function add_measure_analytics() {
// Don't track logged-in admins
if (is_user_logged_in() && current_user_can('manage_options')) {
return;
}
$site_key = 'YOUR_SITE_KEY';
echo '<script
src="https://lets.measure.events/api/script/' . esc_attr($site_key) . '"
data-site="' . esc_attr($site_key) . '"
defer>
</script>';
}
add_action('wp_head', 'add_measure_analytics');
Why Not Google Analytics?
WordPress sites in the EU need a cookie consent banner if they use Google Analytics. That banner typically reduces traffic visibility by 20-40% (users clicking “reject all”). Measure.events uses no cookies and no fingerprinting, so it works without consent banners while staying fully GDPR-compliant.
| Measure.events | Google Analytics 4 | Jetpack Stats | |
|---|---|---|---|
| Cookie consent needed | ❌ | ✅ Required in EU | Varies |
| Script size | 900 bytes | 45KB+ | Bundled (heavy) |
| Price | $29/mo | Free | Free/Paid tiers |
| AI-queryable | ✅ MCP server | ❌ | ❌ |
| Setup time | 5 minutes | 30 minutes | Requires account |
Connecting to Cursor/Claude
Once your data is flowing, add the Measure.events MCP server to your AI coding tool and ask questions like:
- “Which blog posts got the most traffic this week?”
- “What’s my top referral source?”
- “How many visitors came from the newsletter yesterday?”
Your AI assistant can answer these directly from your live analytics data.
Ready to see accurate analytics?
No cookies. No consent banners. No personal data. $29/mo with a 14-day free trial.
Start free trial →