Why Your GTM Tags Aren’t Firing After CookieYes Implementation (And How to Fix It)
You’ve installed CookieYes on your WordPress site, feeling confident about GDPR compliance, when suddenly your Google Analytics shows zero data. Your conversion tracking has vanished. Your marketing campaigns are running blind.
This scenario affects thousands of CookieYes users daily. While CookieYes excels at privacy compliance, its default configuration often blocks GTM tags more aggressively than expected, creating a frustrating disconnect between compliance and data collection.
Many sites experience 60-80% drops in analytics data immediately after CookieYes activation. Here’s how to fix it.
Why CookieYes Blocks GTM Tags
CookieYes takes a privacy-first approach that interferes with GTM in three ways:
- Script Blocking: Automatically blocks known tracking scripts until consent is granted
- Cookie Management: Actively removes cookies from non-consented categories
- Communication Gap: CookieYes and GTM don’t communicate natively—when users grant consent, GTM doesn’t automatically receive this information
Quick Diagnosis: Identify Your Issue
Before fixing, determine your specific problem:
GTM Preview Mode Check:
- Enable GTM Preview Mode with CookieYes active
- Look for tags marked “Not Fired” with “Consent Not Given”
- Check browser console for CookieYes-related errors
Console Debug Commands:
javascript
// Check CookieYes consent state
console.log('CookieYes consent:', document.cookie.includes('cookieyes-consent'));
// Verify GTM loading
console.log('GTM loaded:', typeof window.google_tag_manager !== 'undefined');
Fix #1: Configure CookieYes Script Categories
The most common issue is improper script categorization.
Configure GTM Container as Necessary:
- Go to CookieYes Dashboard → Cookie Settings → Auto Block
- Find “Google Tag Manager” in detected scripts
- Move it to “Necessary” category
- Configure individual tags within GTM for consent
Script Categorization:
- GTM Container: Necessary (it’s the delivery mechanism)
- Google Analytics: Analytics category
- Facebook Pixel: Advertisement category
- Custom tracking: Appropriate category based on function
Fix #2: Implement CookieYes-GTM Consent Bridge
Create communication between CookieYes and GTM using this code (add as Custom HTML tag in GTM):
javascript
<script>
// CookieYes to GTM Consent Bridge
function initializeCookieYesGTMBridge() {
// Initialize GTM Consent Mode defaults
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
'analytics_storage': 'denied',
'ad_storage': 'denied',
'functionality_storage': 'denied',
'security_storage': 'granted'
});
// Update GTM based on CookieYes consent
function updateGTMConsent() {
const ckyCookie = document.cookie
.split('; ')
.find(row => row.startsWith('cookieyes-consent='));
if (ckyCookie) {
const consent = JSON.parse(decodeURIComponent(ckyCookie.split('=')[1]));
gtag('consent', 'update', {
'analytics_storage': consent.analytics ? 'granted' : 'denied',
'ad_storage': consent.advertisement ? 'granted' : 'denied',
'functionality_storage': consent.functional ? 'granted' : 'denied'
});
// Push event for custom triggers
dataLayer.push({
'event': 'cookieyes_consent_update',
'consent_analytics': consent.analytics,
'consent_advertisement': consent.advertisement
});
}
}
// Update immediately and on consent changes
updateGTMConsent();
window.addEventListener('ckyAcceptEvent', updateGTMConsent);
window.addEventListener('ckyRejectEvent', updateGTMConsent);
window.addEventListener('ckySaveEvent', updateGTMConsent);
}
// Initialize the bridge
initializeCookieYesGTMBridge();
</script>
Fix #3: Configure GTM Tags for CookieYes
For Google Analytics 4:
- Edit your GA4 Configuration tag in GTM
- Go to Advanced Settings → Consent Settings
- Require “Analytics Storage”
Create Custom Consent Triggers:
- Trigger Type: Custom Event
- Event Name:
cookieyes_consent_update - Condition:
consent_analyticsequalstrue
For Custom Tags requiring explicit consent:
javascript
<script>
function executeWithConsent() {
const ckyCookie = document.cookie
.split('; ')
.find(row => row.startsWith('cookieyes-consent='));
if (ckyCookie) {
const consent = JSON.parse(decodeURIComponent(ckyCookie.split('=')[1]));
if (consent.analytics) {
// Your analytics code here
gtag('event', 'page_view');
}
if (consent.advertisement) {
// Your marketing code here
fbq('track', 'ViewContent');
}
}
}
executeWithConsent();
window.addEventListener('cookieyes_consent_update', executeWithConsent);
</script>
Fix #4: Resolve WordPress-Specific Issues
Theme Integration: Place GTM code correctly in your WordPress theme:
php
// In functions.php
add_action('wp_head', 'add_gtm_head', 1);
function add_gtm_head() {
?>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {'analytics_storage': 'denied'});
</script>
<!-- GTM Container Code Here -->
<?php
}
Plugin Conflicts:
- Disable conflicting analytics plugins (MonsterInsights, etc.)
- Exclude GTM and CookieYes scripts from caching plugins
- Test each plugin individually
Caching Configuration: For WP Rocket: Settings → Advanced Rules → Never Cache Cookies: cookieyes-consent
Testing Your Integration
Essential Tests:
- Clear browser data and visit your site
- Verify no analytics data before consent
- Grant consent and confirm tags fire immediately
- Test “Accept All,” “Reject All,” and selective consent
- Verify consent persists across sessions
Debug Panel: Add ?cky_debug=1 to your URL and use this debug code in GTM:
javascript
<script>
if (window.location.search.includes('cky_debug=1')) {
setInterval(() => {
const consent = document.cookie.includes('cookieyes-consent=');
const gtmLoaded = typeof window.google_tag_manager !== 'undefined';
console.log('Debug:', {consent, gtmLoaded});
}, 2000);
}
</script>
Common Pitfalls to Avoid
- Double-blocking: Don’t block scripts in both CookieYes AND GTM
- Wrong categories: GTM container should be “Necessary,” not “Analytics”
- Missing bridge: CookieYes and GTM need the consent bridge to communicate
- Caching issues: Exclude consent-related scripts from WordPress caching
Conclusion
CookieYes and GTM can work together perfectly with proper configuration. The key steps are:
- Categorize GTM container as “Necessary” in CookieYes
- Implement the consent bridge code
- Configure GTM tags with consent requirements
- Test all consent scenarios thoroughly
With these fixes, you’ll maintain privacy compliance while preserving accurate analytics data. Your marketing measurement and user trust can coexist successfully.mpliance and accurate data collection. Your analytics and user trust can thrive together.