TLDR: Add GDPR-compliant cookie consent to WooCommerce in 5 minutes. Add GetCookies via functions.php or header.php. Includes automatic Google Consent Mode v2 and works with all caching plugins.
Read full summary
WooCommerce stores need proper cookie consent for EU customers. This guide covers theme integration, conversion tracking, plugin compatibility, and caching considerations. Works with WP Rocket, LiteSpeed, and all major caching solutions.
Summary by Claude AI
"We Got a GDPR Request Today"
A WooCommerce store owner messaged me in a panic. A German customer had filed a data subject access request, asking for all the data the store had collected.
"I just realized," he wrote, "my Pixel has been tracking everyone. Even people who never bought anything. Even people who just visited once. I have tracking data on thousands of Europeans. What do I do?"
This is the nightmare scenario. You've been collecting data you shouldn't have, and now you're legally required to document it all.
The solution isn't damage control. It's prevention. Proper consent management means you only collect data you're legally allowed to keep.
Why WooCommerce Stores Are High-Risk
WordPress and WooCommerce are powerful because of their plugin ecosystem. But every plugin is a potential compliance problem:
| Plugin Type | What It Does | Consent Required? |
|---|---|---|
| Analytics (MonsterInsights, GA) | Tracks visitors | Yes |
| Meta Pixel (PixelYourSite) | Remarketing | Yes |
| Email (Klaviyo, Mailchimp) | Tracks opens/clicks | Yes |
| Live Chat (Tidio, Crisp) | Sets cookies | Often yes |
| Reviews (Yotpo, Judge.me) | Tracks behavior | Often yes |
| Exit popups (OptinMonster) | Tracks engagement | Often yes |
Most store owners install 10-20 plugins. Most of those set cookies. Most don't have consent management.
The 5-Minute Integration
Step 1: Get Your Domain ID
- Sign up at getcookies.co
- Add your domain
- Copy your Domain ID
Step 2: Add to Your Theme
Option A: functions.php (Recommended)
Add to your theme's functions.php or child theme:
// Add GetCookies consent management
function add_getcookies_script() {
?>
<script src="https://getcookies.co/api/v1/widget/loader.js"
data-domain-id="YOUR_DOMAIN_ID"
async></script>
<?php
}
add_action('wp_head', 'add_getcookies_script', 1);
Option B: header.php
Add before </head> in your theme's header.php:
<script src="https://getcookies.co/api/v1/widget/loader.js"
data-domain-id="YOUR_DOMAIN_ID"
async></script>
</head>
Step 3: Test
Visit your site. The consent banner should appear. Accept cookies, check DevTools—your tracking scripts should now fire.
Blocking Scripts Until Consent
Meta Pixel
add_action('wp_head', 'output_meta_pixel_with_consent');
function output_meta_pixel_with_consent() {
?>
<script type="text/plain" data-cookieconsent="marketing">
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}
(window,document,'script','https://connect.facebook.net/en_US/fbevents.js');
fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
</script>
<?php
}
Google Analytics 4
add_action('wp_head', 'output_ga4_with_consent');
function output_ga4_with_consent() {
?>
<script type="text/plain" data-cookieconsent="analytics"
src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXX"
async></script>
<script type="text/plain" data-cookieconsent="analytics">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXX');
</script>
<?php
}
WooCommerce Conversion Tracking
Order Confirmation Page
add_action('woocommerce_thankyou', 'track_woo_conversion_with_consent');
function track_woo_conversion_with_consent($order_id) {
$order = wc_get_order($order_id);
if (!$order) return;
$total = $order->get_total();
$currency = $order->get_currency();
$order_number = $order->get_order_number();
?>
<script>
(function() {
// Check for marketing consent
function hasMarketingConsent() {
try {
var consent = localStorage.getItem('getcookies_consent');
return consent && consent.indexOf('marketing') > -1;
} catch (e) {
return false;
}
}
if (hasMarketingConsent()) {
// Meta Pixel
if (typeof fbq !== 'undefined') {
fbq('track', 'Purchase', {
value: <?php echo $total; ?>,
currency: '<?php echo $currency; ?>',
content_type: 'product'
});
}
// Google Ads
if (typeof gtag !== 'undefined') {
gtag('event', 'conversion', {
'send_to': 'AW-XXXXX/XXXXX',
'value': <?php echo $total; ?>,
'currency': '<?php echo $currency; ?>',
'transaction_id': '<?php echo $order_number; ?>'
});
}
// TikTok Pixel
if (typeof ttq !== 'undefined') {
ttq.track('CompletePayment', {
value: <?php echo $total; ?>,
currency: '<?php echo $currency; ?>'
});
}
}
})();
</script>
<?php
}
Add to Cart Tracking
add_action('wp_footer', 'track_add_to_cart_with_consent');
function track_add_to_cart_with_consent() {
?>
<script>
jQuery(document).on('added_to_cart', function(event, fragments, cart_hash, button) {
if (window.GetCookies && window.GetCookies.hasConsent('marketing')) {
var productId = button.data('product_id');
var productName = button.data('product_name') || '';
var productPrice = button.data('product_price') || 0;
// Meta Pixel
if (typeof fbq !== 'undefined') {
fbq('track', 'AddToCart', {
content_ids: [productId],
content_type: 'product',
value: productPrice,
currency: '<?php echo get_woocommerce_currency(); ?>'
});
}
// TikTok
if (typeof ttq !== 'undefined') {
ttq.track('AddToCart', {
content_id: productId,
content_type: 'product',
value: productPrice,
currency: '<?php echo get_woocommerce_currency(); ?>'
});
}
}
});
</script>
<?php
}
Plugin Compatibility
MonsterInsights / ExactMetrics
Configure to respect consent:
// Disable until consent is given
add_filter('monsterinsights_tracking_disabled', function($disabled) {
// Check for analytics consent
if (isset($_COOKIE['getcookies_consent'])) {
$consent = json_decode(stripslashes($_COOKIE['getcookies_consent']), true);
$categories = $consent['categories'] ?? [];
return !in_array('analytics', $categories);
}
return true; // Disabled by default
});
PixelYourSite
PixelYourSite Pro has consent mode integration. Enable it in: PixelYourSite → General Settings → Consent Mode
Facebook for WooCommerce
The official Facebook plugin respects Google Consent Mode signals. GetCookies sets these automatically.
Klaviyo
Klaviyo's WordPress plugin checks consent signals. Works out of the box with GetCookies.
MailerLite / Mailchimp
Both respect consent when properly configured:
// Only load after marketing consent
window.addEventListener('getcookies:consent', function(e) {
if (e.detail.marketing) {
// Initialize email tracking
}
});
Caching Plugin Compatibility
GetCookies is JavaScript-based, so it works with all caching solutions:
| Plugin | Compatible | Notes |
|---|---|---|
| WP Rocket | ✅ Yes | No special config needed |
| LiteSpeed Cache | ✅ Yes | Works automatically |
| W3 Total Cache | ✅ Yes | Works automatically |
| WP Super Cache | ✅ Yes | Works automatically |
| Autoptimize | ✅ Yes | See note below |
| SG Optimizer | ✅ Yes | Works automatically |
Autoptimize Exclusion (If Needed)
If you use aggressive JS optimization, exclude GetCookies:
add_filter('autoptimize_filter_js_exclude', function($exclude) {
return $exclude . ', getcookies.co';
});
WP Rocket Exclusion (If Needed)
add_filter('rocket_exclude_js', function($excluded_js) {
$excluded_js[] = 'getcookies.co';
return $excluded_js;
});
Usually not needed—GetCookies loads async and handles optimization well.
Multi-Site WordPress (WPMU)
For WordPress multi-site networks:
// Add to mu-plugins/getcookies.php
function getcookies_multisite_init() {
// Each site can have its own domain ID
$domain_id = get_option('getcookies_domain_id');
if ($domain_id) {
echo '<script src="https://getcookies.co/api/v1/widget/loader.js"
data-domain-id="' . esc_attr($domain_id) . '"
async></script>';
}
}
add_action('wp_head', 'getcookies_multisite_init', 1);
Each site can have its own GetCookies domain in the network.
WPML / Polylang Multi-Language
GetCookies auto-detects browser language, but you can also configure per-language:
function getcookies_with_language() {
// Get current language
$lang = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : 'en';
// Map languages to domain IDs if needed
$domain_ids = [
'en' => 'YOUR_EN_DOMAIN_ID',
'de' => 'YOUR_DE_DOMAIN_ID',
'fr' => 'YOUR_FR_DOMAIN_ID'
];
$domain_id = $domain_ids[$lang] ?? $domain_ids['en'];
?>
<script src="https://getcookies.co/api/v1/widget/loader.js"
data-domain-id="<?php echo esc_attr($domain_id); ?>"
async></script>
<?php
}
add_action('wp_head', 'getcookies_with_language', 1);
WooCommerce Subscriptions
Track subscription events with consent:
add_action('woocommerce_subscription_status_active', function($subscription) {
$total = $subscription->get_total();
?>
<script>
if (window.GetCookies && window.GetCookies.hasConsent('marketing')) {
if (typeof fbq !== 'undefined') {
fbq('track', 'Subscribe', {
value: <?php echo $total; ?>,
currency: '<?php echo get_woocommerce_currency(); ?>',
predicted_ltv: <?php echo $total * 12; ?>
});
}
}
</script>
<?php
});
WooCommerce Bookings
Track bookings with consent:
add_action('woocommerce_booking_confirmed', function($booking_id) {
$booking = get_wc_booking($booking_id);
$cost = $booking->get_cost();
?>
<script>
if (window.GetCookies && window.GetCookies.hasConsent('marketing')) {
if (typeof fbq !== 'undefined') {
fbq('track', 'Schedule', {
value: <?php echo $cost; ?>,
currency: '<?php echo get_woocommerce_currency(); ?>'
});
}
}
</script>
<?php
});
Testing Your Implementation
Quick Test
- Open your store in incognito
- Open DevTools → Network tab
- Filter by "facebook", "google", "tiktok"
- Before consent: No matching requests
- Accept marketing cookies
- Refresh: Requests should appear
Full Checklist
- Banner appears on first visit
- Banner respects your theme styling
- "Accept All" enables all tracking
- "Reject All" blocks marketing/analytics
- Consent persists across pages
- Shop page respects consent
- Product pages respect consent
- Cart page respects consent
- Checkout page respects consent
- Order confirmation tracks with consent only
- Caching doesn't break consent
- Mobile banner works correctly
Performance Impact
GetCookies on WooCommerce:
| Metric | Impact |
|---|---|
| Script size | ~1.6 KB (gzipped) |
| Loading | Async, non-blocking |
| CLS | Zero layout shift |
| LCP | No impact |
| FID | No impact |
Your PageSpeed scores stay healthy. WooCommerce is often slower due to other plugins—GetCookies won't make it worse.
Common Issues and Fixes
Banner Not Appearing
- Check browser console for errors
- Verify Domain ID is correct
- Clear any caching (page cache, CDN)
- Check if another consent plugin is conflicting
Tracking Still Firing Before Consent
- Verify
type="text/plain"is on tracking scripts - Check if a plugin is injecting scripts directly
- Look for tracking code in theme files
Consent Not Persisting
- Check if localStorage is blocked
- Verify no privacy extensions are clearing data
- Check for cross-domain issues
The Bottom Line
That store owner I mentioned earlier? He had to send data subject access responses to 14 different customers before implementing proper consent.
After GetCookies:
- Automatic compliance for all new visitors
- No more panicked GDPR requests
- Customer trust restored
The EU isn't backing down on privacy. WooCommerce makes it easy to sell to Europe—GetCookies makes it legal.
Ready to make your WooCommerce store compliant?