With your AI coding agent

Ask your agent to integrate React/Vite

A brief for a client-rendered app with consent defaults in index.html.

Home / Ask your agent to integrate React/Vite

Before you start

  1. Create an account and a workspace, then activate a plan. Create account
  2. Add the site, authorize every exact host, and configure its policy and categories.
  3. Open Sites → your site → Installation. Replace the public site-key marker below with the key shown there. Open dashboard

Put each part in the right place

index.html comes before src/main.tsx. Mount the provider once at the root.

  1. Ask the agent to inspect every script in index.html and remove duplicate tag loaders.
  2. Make the preferences button available on every route, not just the homepage.
Integration brief
Integrate Mayicookies into this vite website. First inspect the framework, root document, and all analytics/marketing loaders. Use @supaapps/mayicookies or the official hosted loader, not a homemade banner.

Public site key: REPLACE_WITH_YOUR_PUBLIC_SITE_KEY
API URL: https://api.mayicookies.com/api
Runtime: npm; Google integration: gtm

Use the matching guide at https://mayicookies.com/en/tutorials/agent-react/ and the framework installation guide. Put denied consent defaults before GTM/gtag.js, never only in useEffect. Do not use the direct Google bridge with the GTM template. Block optional non-GTM scripts with type="text/plain" and data-mayicookies-category. Add a persistent Cookie settings button. Do not assume autoBlock intercepts arbitrary scripts.

Never ask for passwords, access tokens, or private API credentials. Do not modify billing, accounts, or GTM permissions. Report GTM account steps separately from code changes. For Basic Consent Mode, block Google tags until consent; denied defaults alone can still allow cookieless pings.

Show the changed files and prove in a fresh browser: no optional cookies before consent; reject/analytics-only/accept update correctly; withdrawal works; a saved consent appears in Mayicookies; defaults remain denied with slow loading. Do not claim legal compliance or certification.
npm
npm install @supaapps/mayicookies
Early denied defaults · before Google
<script>
window.dataLayer = window.dataLayer || [];
window.__mayicookiesConsentModeListeners = window.__mayicookiesConsentModeListeners || new Set();
window.mayicookiesAddConsentModeListener = window.mayicookiesAddConsentModeListener || function(listener) {
  window.__mayicookiesConsentModeListeners.add(listener);
  return function() { window.__mayicookiesConsentModeListeners.delete(listener); };
};
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
  ad_storage: 'denied', ad_user_data: 'denied', ad_personalization: 'denied',
  analytics_storage: 'denied', functionality_storage: 'denied',
  personalization_storage: 'denied', security_storage: 'granted', wait_for_update: 500
});
</script>
Runtime
'use client';
import { useEffect } from 'react';
import { Mayicookies } from '@supaapps/mayicookies';

export function MayicookiesProvider() {
  useEffect(() => {
    void Mayicookies.init({
      siteKey: "REPLACE_WITH_YOUR_PUBLIC_SITE_KEY",
      apiUrl: "https://api.mayicookies.com/api",
      mode: 'auto',
      locale: 'auto',
      autoBlock: true,
      googleConsentMode: { waitForUpdate: 500 },
    });
  }, []);
  return null;
}
Document / root placement
<!-- index.html -->
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script>
window.dataLayer = window.dataLayer || [];
window.__mayicookiesConsentModeListeners = window.__mayicookiesConsentModeListeners || new Set();
window.mayicookiesAddConsentModeListener = window.mayicookiesAddConsentModeListener || function(listener) {
  window.__mayicookiesConsentModeListeners.add(listener);
  return function() { window.__mayicookiesConsentModeListeners.delete(listener); };
};
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
  ad_storage: 'denied', ad_user_data: 'denied', ad_personalization: 'denied',
  analytics_storage: 'denied', functionality_storage: 'denied',
  personalization_storage: 'denied', security_storage: 'granted', wait_for_update: 500
});
</script>
    
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.tsx"></script>
  </body>
</html>

// src/main.tsx
import { createRoot } from 'react-dom/client';
import App from './App';
import { MayicookiesProvider } from './MayicookiesProvider';

createRoot(document.getElementById('root')!).render(
  <><MayicookiesProvider /><App /></>,
);

Next: import the GTM template and configure consent checks. A script installation alone does not finish your GTM setup. GTM Tutorials

Download GTM template

Basic / Advanced Consent Mode

Basic mode blocks Google tags until the relevant consent. Advanced mode loads tags with denied defaults and can send cookieless pings. Choose deliberately: denied storage is not the same as no network requests. The GTM template communicates choices; your tag checks control what fires.

Other optional scripts

HTML
<script type="text/plain" data-mayicookies-category="analytics" src="https://YOUR_ANALYTICS_HOST/script.js"></script>

Replace the vendor URL and use a category key configured on the site. Do not leave a second active copy of the vendor script elsewhere.

Keep cookie settings accessible

Place this control in a shared footer or privacy page so visitors can withdraw or change consent.

Preferences control
'use client';
import { Mayicookies } from '@supaapps/mayicookies';

export function CookieSettings() {
  return <button type="button" onClick={() => Mayicookies.openPreferences()}>Cookie settings</button>;
}

Multilingual websites

Set the page's HTML lang attribute. The CMP follows it automatically; configure custom wording and translated privacy links under Consent Policy → Languages in the dashboard. For client-side language switches, call Mayicookies.setLocale(language) instead of rewriting banner text in the DOM. A language change preserves consent. Review translations of your own purposes; those are not automatically translated.

Check the actual browser behavior

  1. Before consent, check that _ga and _ga_* are absent. In Basic mode, check that no Google analytics requests were sent.
  2. Test reject, analytics-only, marketing, preference changes, withdrawal, and GPC. Repeat with slow network loading.
  3. Check a saved record in the dashboard. A received record proves API activity, not correct tag ordering.
  4. Use GTM Preview and Tag Assistant to confirm defaults and updates. Check both analytics and ad-related signals.

Common failures

403 / config
Authorize the exact host, including www when used.
404 / config
Check the site key and API URL copied from Installation.
Google cookies before consent
Inspect tag order, duplicated loaders, and consent checks. Do not solve this by delaying the banner.
No recorded choice
Check the consent POST, billing status, and remaining record allowance. A local saved choice does not prove successful server recording.

Mayicookies manages consent mechanics, not your legal assessment. It does not scan for cookies or automatically intercept scripts you have not configured. Google Consent Mode support is not Google CMP certification. Review your notices and test every optional tag.

Need help with this setup?