Skip to content

StackOS Community Q&A • security

How to set up GDPR-compliant cookie consent that actually works?

We need to implement cookie consent on our SaaS platform that serves EU customers. We're not sure what level of consent is required: - Do we need explicit opt-in for analytics cookies? - What about essential cookies vs marketing cookies? - Any recommended tools or should we build custom? - How does this affect our Google Analytics and HubSpot tracking?

Top Community Answer

Yes, you need explicit opt-in for non-essential cookies under GDPR. Here's the complete breakdown: **Cookie categories and consent requirements:** 1. **Strictly necessary** — No consent needed (auth, shopping cart, security) 2. **Functional** — Consent required (language preference, theme) 3. **Analytics** — Consent required (GA, Mixpanel, Hotjar) 4. **Marketing/Advertising** — Consent required (Facebook Pixel, Google Ads, HubSpot tracking) **Tool recommendation: Cookiebot** (by Usercentrics) or OneTrust. Both handle: - Auto-detection of cookies on your site - Granular consent categories - Geolocation (show different banners for EU vs non-EU) - Consent audit logs (required for compliance) **Implementation with Google Analytics:** Before consent: Don't load GA at all, or load in cookieless mode. After consent: Dynamically initialize GA with the consent state. Use gtag consent update method to enable analytics only after opt-in. **Implementation with HubSpot:** HubSpot has a built-in cookie consent API. Set window._hsq.push revokeCookieConsent by default, then call grantCookieConsent() after user opts in. **Key compliance requirements:** - No pre-ticked checkboxes - Equal prominence for accept/reject buttons - Easy withdrawal of consent (must be as easy as giving it) - Cookie policy must link to full privacy policy