How to Implement Google Consent Mode v2 on Squarespace

If you use Google Ads or Google Analytics and target visitors in the European Economic Area (EEA) or the UK, implementing Google Consent Mode v2 is now a requirement.

While Squarespace provides a built-in cookie banner, it does not automatically communicate a user's choice to Google’s Consent Mode API. This guide provides the code needed to bridge that gap.


The Problem

Squarespace’s native cookie banner successfully blocks or allows cookies on your site, but it doesn't send the specific "signals" (like ad_user_data or ad_personalization) that Google Ads now requires to track conversions and build remarketing audiences effectively.

The Solution: 3-Step Integration

1. Enable the Squarespace Cookie Banner

First, ensure your built-in banner is active and configured correctly:

  • Navigate to Settings > Cookies & Visitor Data.

  • Turn on the Cookie Banner.

  • Set the Cookie Banner Type to "Opt In & Out". This is essential to give users a choice.

2. Clear Existing Google Code

If you have manually added Google Ads or Analytics scripts to your Header Code Injection, remove them. This new script will handle the loading and configuration for you.

3. Add the Integration Code

Go to Website > Website Tools > Code Injection and paste the following into the Header section.

Note: Replace AW-XXXXXXXXX with your actual Google Ads Tag ID (or your GTM/GA4 ID).

<script async src="https://www.googletagmanager.com/gtag/js?id=AW-XXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}

  // 1. Set default consent state (denied)
  gtag('consent', 'default', {
    'ad_storage': 'denied',
    'ad_user_data': 'denied',
    'ad_personalization': 'denied',
    'analytics_storage': 'denied'
  });

  gtag('js', new Date());
  gtag('config', 'AW-XXXXXXXXX');

  // 2. Function to sync Squarespace banner choice with Google
  const syncConsent = () => {
    let squarespaceCookies = {};
    if (window.getSquarespaceCookies) {
      squarespaceCookies = window.getSquarespaceCookies();
    }
    
    // Check if user accepted 'marketing' cookies in Squarespace
    const consentValue = squarespaceCookies.marketing === 'accepted' ? 'granted' : 'denied';
    
    gtag('consent', 'update', {
      'ad_storage': consentValue,
      'ad_user_data': consentValue,
      'ad_personalization': consentValue,
      'analytics_storage': consentValue
    });
  };

  // 3. Run on page load and on banner interaction
  syncConsent();
  window.onCookieBannerInteraction = () => {
    syncConsent();
  };
</script>

Frequently Asked Questions


What is Consent Mode v2?

It is a framework from Google that allows your website to communicate user consent for advertising and analytics. Version 2 includes mandatory parameters for personalized ads (ad_user_data and ad_personalization).


Can I use this with Google Tag Manager (GTM)?

Yes. Simply replace the AW-XXXXXXXXX ID in the code with your GTM Container ID (e.g., GTM-XXXXXXX).


How do I verify it’s working?

Use the Google Tag Assistant (preview mode). Check the "Consent" tab for your tags; it should show "Denied" by default when you first land on the page and switch to "Granted" immediately after you click "Accept" on your banner.


What happens if I don’t implement this?

Without Consent Mode v2, Google Ads will stop capturing data for new users in the EEA and UK. This will lead to inaccurate conversion tracking and the inability to run remarketing campaigns.


Does this affect my SEO?

No. This script only manages how data is handled based on user privacy choices and does not impact your site’s ranking or performance.

Previous
Previous

How to Take Orders Without Immediate Payment on Squarespace

Next
Next

How to Connect Your GoDaddy Domain to Squarespace