GDPRChecker

Home / Knowledge Base / Vue Consent Mode v2 Setup Guide: Practical Steps for Website Owners

Website Compliance

Vue Consent Mode v2 Setup Guide: Practical Steps for Website Owners

A practical Vue consent mode v2 setup guide covering implementation steps, common mistakes, and validation with GDPRChecker scans. Learn how to configure consent defaults, update signals on user action, and verify pre-consent network requests.

Run a free GDPR compliance scanPreview the findings before choosing a CMP.

Author

GDPRChecker Editorial Team

Reviewed by

Privacy & Compliance Research Team

Last updated

July 2026

Reading time

12 min read

Educational guidance for compliance readiness — not legal advice. Requirements vary by jurisdiction and your specific processing activities.

Introduction

Updated for 2026 compliance practices.

Understanding how to properly configure consent mode in a Vue.js application is essential for website owners who want to align with privacy expectations while maintaining analytics and advertising functionality. This Vue consent mode v2 setup guide provides a technical walkthrough focused on implementation and verification, not legal advice. Whether you are integrating Google tags, managing a cookie banner, or preparing for a compliance scan, the steps below will help you close common gaps.

Consent mode v2 introduces two new consent signals—ad_user_data and ad_personalization—alongside the existing analytics_storage and ad_storage. For Vue developers, this means updating how the global gtag function or Google Tag Manager (GTM) container receives consent state. The goal is to ensure that tags respect user choices before any network request fires. A practical Vue consent mode v2 setup guide must address default consent state, update triggers, and post-change validation.

This guide is part of GDPRChecker’s knowledge base expansion, designed to help you implement and verify consent mode without relying on generic templates. We will cover requirements, step-by-step implementation, common mistakes, and how to use GDPRChecker scans to confirm everything works. For broader context, you may also want to review our Google Consent Mode v2 guide and the article on cookie banner requirements.

Requirements and Compliance Expectations

Before diving into code, it is important to understand the technical requirements that a Vue consent mode v2 setup guide must satisfy. These are not legal mandates but technical prerequisites for consent mode to function as intended. The official Google Consent Mode documentation outlines the necessary signals and default values. Additionally, European Data Protection Board (EDPB) guidance emphasizes that consent must be freely given, specific, informed, and unambiguous. See EDPB Guidelines 05/2020 on consent. While this guide does not provide legal advice, aligning your implementation with these principles is a sensible step.

Technical Prerequisites

  • A Google tag (gtag.js) or Google Tag Manager container loaded in your Vue app.
  • A consent management mechanism (custom banner, CMP, or GDPRChecker’s recommended approach).
  • The ability to set window.dataLayer or call gtag('consent', 'default', {...}) before any tags fire.
  • For GTM users, consent mode triggers configured in the container.

Consent Signals in v2

Consent mode v2 requires four consent types: - analytics_storage: Controls whether analytics cookies can be set. - ad_storage: Controls whether advertising cookies can be set. - ad_user_data: Controls whether user data can be sent to Google for advertising purposes. - ad_personalization: Controls whether personalized advertising is enabled.

Each must be set to either 'granted' or 'denied' by default. The default state should be 'denied' for all except perhaps analytics_storage if you have a legal basis other than consent, but that is a decision for your legal team. This Vue consent mode v2 setup guide assumes a conservative default of 'denied' for all signals.

Integration with Vue

In a Vue app, you typically load the Google tag or GTM script in index.html or via a plugin. The key is to push the default consent command before the script loads or immediately after, but before any tags fire. This often requires careful ordering in the Vue lifecycle. If you use a CMP, it should handle this automatically; if you build a custom solution, you must implement the logic yourself.

How to Implement Step by Step

This section of the Vue consent mode v2 setup guide walks through a practical implementation using a custom consent banner in a Vue 3 application. The same principles apply to Vue 2 with minor syntax differences. We will cover setting default consent, updating consent on user action, and integrating with Google Tag Manager.

Step 1: Set Default Consent State

In your index.html, before the Google tag or GTM script, add a script block that pushes the default consent to the data layer. This ensures that even if the tag loads before your Vue app mounts, the default 'denied' state is already in place.

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
  'analytics_storage': 'denied',
  'ad_storage': 'denied',
  'ad_user_data': 'denied',
  'ad_personalization': 'denied',
  'wait_for_update': 500
});

The wait_for_update parameter tells Google tags to wait up to 500 milliseconds for an update call before firing. This is useful if your Vue app sets consent quickly after mounting. Adjust the timeout based on your app’s initialization speed.

Step 2: Load Google Tag or GTM

After the default consent script, load your Google tag or GTM container. For GTM, the snippet typically looks like:

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->

Replace GTM-XXXXXX with your container ID. If using gtag.js directly, the snippet is similar but with your measurement ID.

Step 3: Create a Consent Banner Component in Vue

Build a Vue component that displays a cookie consent banner. The banner should have “Accept All” and “Reject All” buttons, and optionally a settings panel for granular choices. Store the user’s consent preferences in a reactive state and in localStorage so they persist across sessions.

Example component structure:

<template>
  <div v-if="!consentDecided" class="consent-banner">
    <p>We use cookies to improve your experience. By clicking "Accept All", you consent to our use of cookies. <a href="/privacy-policy">Learn more</a></p>
    <button @click="acceptAll">Accept All</button>
    <button @click="rejectAll">Reject All</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      consentDecided: localStorage.getItem('consentDecided') === 'true'
    }
  },
  methods: {
    acceptAll() {
      this.updateConsent({
        analytics_storage: 'granted',
        ad_storage: 'granted',
        ad_user_data: 'granted',
        ad_personalization: 'granted'
      });
      this.consentDecided = true;
      localStorage.setItem('consentDecided', 'true');
    },
    rejectAll() {
      this.updateConsent({
        analytics_storage: 'denied',
        ad_storage: 'denied',
        ad_user_data: 'denied',
        ad_personalization: 'denied'
      });
      this.consentDecided = true;
      localStorage.setItem('consentDecided', 'true');
    },
    updateConsent(consent) {
      gtag('consent', 'update', consent);
      // If using GTM, also push to dataLayer for custom triggers
      window.dataLayer.push({
        event: 'consent_update',
        consent: consent
      });
    }
  },
  mounted() {
    // If consent was previously decided, re-apply it
    if (this.consentDecided) {
      const savedConsent = JSON.parse(localStorage.getItem('consentPreferences'));
      if (savedConsent) {
        this.updateConsent(savedConsent);
      }
    }
  }
}
</script>

This component checks localStorage on mount to see if consent was already decided. If so, it re-applies the saved preferences. Otherwise, it shows the banner. When the user clicks a button, it updates consent via gtag('consent', 'update', ...) and pushes a custom event to the data layer for GTM triggers.

Step 4: Configure GTM Triggers (If Using GTM)

If you use Google Tag Manager, you need to set up triggers that fire tags based on consent state. In GTM, create a Custom Event trigger named “consent_update” and use it to fire tags that require consent. Additionally, configure built-in consent settings in your GTM container:

  • Go to Admin > Container Settings > Additional Settings > Consent Overview.
  • Enable consent for the relevant tags (e.g., Google Analytics 4, Google Ads).
  • Set the default consent for each tag type to “No additional consent required” if you handle consent via the data layer, or use GTM’s consent initialization.

For tags that should only fire when specific consent is granted, use trigger exceptions based on the consent state stored in a data layer variable. This Vue consent mode v2 setup guide recommends testing thoroughly with GTM’s preview mode.

Step 5: Handle Page Navigation in Vue

In a Vue SPA, the consent banner should not reappear on every route change. Use Vue Router’s navigation guards or a global state to ensure the banner only shows once per session. The consentDecided flag in localStorage already handles this across full page reloads, but within the SPA, make sure the banner component is only mounted once (e.g., in App.vue).

Step 6: Verify Pre-Consent Network Requests

After implementation, open your browser’s developer tools, go to the Network tab, and reload the page before giving consent. You should see that Google tags (like gtag/js, analytics.js, or gtm.js) may load, but they should not set cookies or send requests with identifiers. Look for requests to google-analytics.com or doubleclick.net; they should either be absent or contain the gcs parameter indicating consent state. For example, a request with gcs=G100 means all consent denied.

If you see cookies being set or full requests firing before consent, your default consent command may not be executing early enough. Double-check the script order in index.html.

Common Mistakes and How to Avoid Them

Even with a detailed Vue consent mode v2 setup guide, implementation errors can occur. Here are the most frequent pitfalls and how to address them.

Mistake 1: Default Consent Set Too Late

If the gtag('consent', 'default', ...) call happens after the Google tag script has already loaded and fired, the default will be ignored. Always place the default consent script before the tag snippet. In a Vue app, this means putting it in index.html rather than inside a Vue component’s mounted hook.

Mistake 2: Not Updating Consent on User Action

Some implementations set the default but never call gtag('consent', 'update', ...) when the user makes a choice. Without the update call, tags remain in the default state (usually denied) even after the user accepts. Ensure your banner buttons trigger the update function.

Mistake 3: Ignoring the Reject Flow

A common oversight is not testing what happens when the user clicks “Reject All.” Tags should still fire but in consent mode’s cookieless pings. Verify that analytics still records basic page views (if configured) and that advertising tags do not set cookies. GDPRChecker scans can help confirm that no unauthorized cookies are set after rejection.

Mistake 4: Hardcoding Consent for Testing

During development, you might temporarily set all consent to 'granted' to see data in analytics. Forgetting to revert this before production will cause all users to be treated as if they consented, undermining the entire setup. Use environment variables or a debug flag that is disabled in production.

Mistake 5: Not Handling Granular Consent

If your banner offers granular options (e.g., separate toggles for analytics and marketing), you must map those to the correct consent signals. Failing to do so may result in over-granting or under-granting. For example, if a user accepts analytics but not marketing, analytics_storage should be 'granted' while ad_storage remains 'denied'.

Mistake 6: Overlooking Policy Disclosures

Consent mode does not replace the need for a privacy policy or cookie disclosure. Your banner should link to a privacy policy that explains what data is collected and how it is used. GDPRChecker scans can detect missing policy links, helping you close that gap.

How to Validate with GDPRChecker

After following this Vue consent mode v2 setup guide, validation is crucial. GDPRChecker provides automated scans that simulate user journeys and check for compliance gaps. Here is how to use it effectively.

Pre-Scan Preparation

  • Ensure your Vue app is deployed to a staging or production environment accessible to the scanner.
  • Clear any existing consent cookies so the scanner sees the default state.
  • If your site uses geolocation-based banner display, make sure the scanner’s IP is not excluded.

Running a Scan

  1. Log in to your GDPRChecker account and navigate to the scan dashboard.
  2. Enter the URL of your Vue app.
  3. Configure scan options: choose whether to simulate consent acceptance, rejection, or no interaction.
  4. Start the scan and wait for the report.

Interpreting Results

The scan report will highlight: - Pre-consent network requests: Any tags that fired before consent was given. - Banner behavior: Whether the banner appeared, and if the accept/reject buttons work. - Disclosure gaps: Missing privacy policy links or incomplete cookie descriptions. - Consent state after interaction: Whether the correct signals were updated.

Use these results to fine-tune your implementation. For example, if the scanner detects a request to doubleclick.net before consent, you may need to adjust your default consent timing. For more details on scanner capabilities, see our Google Consent Mode v2 checker.

Continuous Monitoring

Compliance is not a one-time task. After any update to your Vue app, tags, or CMP, run a new scan to catch regressions. GDPRChecker can be integrated into your CI/CD pipeline for automated checks on every deployment.

Implementation Checklist

Use this checklist to ensure you have covered all steps in this Vue consent mode v2 setup guide:

  1. Default consent command placed before Google tag/GTM script in index.html.
  2. All four consent signals (analytics_storage, ad_storage, ad_user_data, ad_personalization) set to 'denied' by default.
  3. Google tag or GTM snippet loads after default consent.
  4. Vue consent banner component created with Accept All and Reject All buttons.
  5. Banner stores consent decision in localStorage to prevent reappearing.
  6. gtag('consent', 'update', ...) called on user action with correct consent values.
  7. Custom event pushed to data layer for GTM triggers (if using GTM).
  8. GTM triggers configured to respect consent state (if using GTM).
  9. Pre-consent network requests verified: no cookies set before consent.
  10. Reject flow tested: tags fire in cookieless mode, no advertising cookies.
  11. Privacy policy link included in banner and accessible.
  12. GDPRChecker scan run with acceptance and rejection scenarios, all issues resolved.

FAQ

What is Vue consent mode v2 setup guide?

A Vue consent mode v2 setup guide is a technical resource that explains how to configure Google’s consent mode in a Vue.js application. It covers setting default consent signals, updating them based on user choices, and verifying that tags respect those choices. This guide focuses on practical implementation steps for website owners.

Do I need Vue consent mode v2 setup guide for GDPR?

While not a legal requirement, implementing consent mode v2 helps align your Vue site with GDPR principles by giving users control over their data. It ensures that Google tags do not set cookies or send identifiers without consent. Whether you need it depends on your use of Google services and the legal basis you rely on; consult your legal team.

How do I implement Vue consent mode v2 setup guide?

Implementation involves setting a default 'denied' consent state before loading Google tags, building a consent banner in Vue that calls gtag('consent', 'update', ...) on user action, and configuring GTM triggers if applicable. Detailed steps are provided in this guide’s implementation section.

How can I verify Vue consent mode v2 setup guide with a scanner?

Use GDPRChecker to scan your Vue site. The scanner checks pre-consent network requests, banner behavior, and consent state updates. Run scans simulating both acceptance and rejection to ensure tags behave correctly. Address any flagged issues to close compliance gaps.

What are common Vue consent mode v2 setup guide mistakes?

Common mistakes include setting default consent too late, forgetting to call the update function, not testing the reject flow, hardcoding consent for testing, ignoring granular preferences, and missing policy disclosures. This guide details how to avoid each of these pitfalls.

GDPRChecker guides are educational resources and do not constitute legal advice. Use them to understand technical and operational privacy requirements, and consult qualified counsel for legal interpretation.

Check Your Website in Under 60 Seconds

  • Sign in required
  • GDPR-focused checks
  • Cookie banner detection
  • Privacy policy verification