Script Integration
How to add the Cookiewise consent banner to any website, CMS, or platform.
Basic Installation
Add the following script tag as the very first script after your opening <head> tag, before any analytics or marketing scripts:
<script src="https://www.cookiewise.net/api/script.js?website_id=YOUR_WEBSITE_ID"></script>
The script is lightweight (~8KB gzipped), loads asynchronously, and does not block page rendering.
Platform-Specific Guides
WordPress
Two options for WordPress integration:
- Theme header: Add the script to
header.phpin your theme, as the first script after<head> - Plugin: Use a plugin like "Insert Headers and Footers" or "WPCode" to add the script without editing theme files
Shopify
- Go to Online Store → Themes → Edit code
- Open
theme.liquid - Paste the script tag as the first item after the opening
<head>tag - Save
Webflow
- Open Project Settings → Custom Code
- Paste the script in the Head Code section
- Publish your site
Google Tag Manager
- Create a new Custom HTML tag
- Paste the script tag
- Set trigger to All Pages - Page View
- Set priority to fire before other tags
Cookiewise includes native Google Consent Mode v2 support. When the script loads, it automatically:
- 1. Sets
gtag('consent', 'default', ...)with correct initial states - 2. Fires
gtag('consent', 'update', ...)when visitors accept, reject, or customise cookies - 3. Maps cookie categories to Google signals: analytics to
analytics_storage, marketing toad_storage/ad_user_data/ad_personalization
You do not need a separate Consent Mode snippet. Just load the Cookiewise script before your GA4 or GTM code.
Next.js / React
Add to your _document.tsx or root layout:
<Head> <script src="https://www.cookiewise.net/api/script.js?website_id=YOUR_ID" /> </Head>
Script Parameters
| Parameter | Required | Description |
|---|---|---|
| website_id | Yes | Your unique website identifier from the dashboard |
| lang | No | Force a specific language (e.g., en, de, fr) |
| debug | No | Set to true to enable console logging |
Google Analytics 4 Integration
With built-in Consent Mode v2, GA4 setup is straightforward. Place the Cookiewise script first, then your GA4 code:
<!-- 1. Cookiewise (in <head>) -->
<script src="https://www.cookiewise.net/api/script.js?website_id=YOUR_ID"></script>
<!-- 2. GA4 (before </body> or in <head>) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
That's it. Cookiewise sets consent defaults before GA4 initialises, then updates consent signals when visitors interact with the banner. GA4 responds dynamically - no page reload needed for analytics to start flowing.
If your site uses Content Security Policy headers, use wildcard domains: https://*.google-analytics.com and https://*.googletagmanager.com in your script-src, img-src, and connect-src directives. GA4 uses regional endpoints (e.g. region1.google-analytics.com) that exact-match rules will silently block.
Verifying Installation
After adding the script, verify it's working:
- Open your website in an incognito/private browser window
- The consent banner should appear within 1-2 seconds
- Open browser DevTools - Console and look for
Cookiewise: initialized - Check the Network tab for a successful request to
cookiewise.net/api/script.js - In the Console, type
Cookiewise.getConsentMode()- should returntrue - Accept cookies, then check GA4 Realtime to confirm data is flowing