Cookie Consent
CubeConnect uses a lightweight, built-in cookie consent banner on the landing page. This guide explains the cookie categories, how consent is stored, and how to conditionally load scripts based on user preferences.
Cookie Categories
| Category | Required | Description |
|---|---|---|
| Essential | Yes | Session cookies, CSRF tokens, authentication. Always active. |
| Analytics | No | Usage analytics and performance monitoring (e.g., Google Analytics). |
| Marketing | No | Advertising pixels and remarketing tags (e.g., Meta Pixel, Google Ads). |
How It Works
- On the first visit, a banner appears at the bottom of the page
- The user can toggle Analytics and Marketing cookies, or accept all
- Preferences are saved to
localStorageunder the keycookie_consent - The banner does not appear again unless consent is cleared
Consent Storage Format
Preferences are stored as a JSON string in localStorage:
json
{
"essential": true,
"analytics": true,
"marketing": false,
"timestamp": "2026-02-27T12:00:00.000Z"
}Reading Consent in JavaScript
Use the helper below to check if a specific category was accepted:
javascript
function hasCookieConsent(category) {
try {
const consent = JSON.parse(localStorage.getItem('cookie_consent'))
return consent?.[category] === true
} catch {
return false
}
}
// Examples
hasCookieConsent('analytics') // true or false
hasCookieConsent('marketing') // true or false
hasCookieConsent('essential') // always true once savedConditionally Loading Scripts
Only load third-party scripts after the user has given consent:
Google Analytics
html
<script>
if (hasCookieConsent('analytics')) {
const script = document.createElement('script')
script.src = 'https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX'
script.async = true
document.head.appendChild(script)
window.dataLayer = window.dataLayer || []
function gtag() { dataLayer.push(arguments) }
gtag('js', new Date())
gtag('config', 'G-XXXXXXXXXX')
}
</script>Meta Pixel
html
<script>
if (hasCookieConsent('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>Cookies Reference
| Cookie | Category | Duration | Description |
|---|---|---|---|
XSRF-TOKEN | Essential | Session | CSRF protection token |
cube_session | Essential | 2 hours | User session identifier |
cookie_consent | Essential | Permanent | Stored in localStorage — user's consent preferences |
_ga / _gid | Analytics | 2 years / 24h | Google Analytics tracking |
_fbp | Marketing | 90 days | Meta Pixel browser identification |
_gcl_au | Marketing | 90 days | Google Ads conversion linker |
Resetting Consent
To allow a user to change their preferences, clear the stored consent:
javascript
localStorage.removeItem('cookie_consent')
// Reload the page to show the banner again
location.reload()TIP
You can add a "Cookie Settings" link in your footer that calls the reset function above, giving users a way to update their preferences at any time.