PHPackages                             pixelperfectat/module-hyva-cookie-consent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. pixelperfectat/module-hyva-cookie-consent

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

pixelperfectat/module-hyva-cookie-consent
=========================================

GDPR/ePrivacy-compliant cookie consent management for Hyva theme

0.3.0(3mo ago)4761MITJavaScriptPHP ^8.3

Since Jan 3Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/pixelperfectat/module-hyva-cookie-consent)[ Packagist](https://packagist.org/packages/pixelperfectat/module-hyva-cookie-consent)[ RSS](/packages/pixelperfectat-module-hyva-cookie-consent/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

Pixelperfect Hyva Cookie Consent
================================

[](#pixelperfect-hyva-cookie-consent)

GDPR/ePrivacy-compliant cookie consent management for Magento 2 with Hyva theme.

Features
--------

[](#features)

- **Actually blocks cookies** until explicit consent is given
- **Google Consent Mode v2** support - GTM/GA4 automatically respect consent
- **CSP Strict Mode** compatible - works with Content Security Policy
- **Full Page Cache** compatible - consent handled client-side
- **Category-based consent** - Necessary, Analytics, Marketing, Preferences
- **XML configuration** - Define categories, services, and cookies via XML
- **Built-in service templates** - GTM, GA4, Facebook Pixel, Microsoft Clarity, Hotjar, Matomo
- **Floating settings button** - Users can change preferences anytime
- **Multi-language** - EN, DE, FR, ES, IT translations included

Requirements
------------

[](#requirements)

- Magento 2.4.x
- PHP 8.3+
- Hyva Theme

Installation
------------

[](#installation)

```
composer require pixelperfectat/module-hyva-cookie-consent
bin/magento setup:upgrade
bin/magento cache:flush
```

Configuration
-------------

[](#configuration)

### Admin Settings

[](#admin-settings)

Navigate to **Stores → Configuration → Web → Cookie Consent (Hyva)**

SettingDescriptionEnable Cookie ConsentEnable/disable the moduleConsent Cookie LifetimeDays to remember consent (default: 365)Consent VersionIncrement to force re-consent after policy changesBanner StyleModal (center overlay) or Bar (bottom fixed)Floating Button PositionLeft or RightBanner Headline/DescriptionCustomizable textPrivacy Policy URLLink to your privacy policy### Service Configuration

[](#service-configuration)

Navigate to **Stores → Configuration → Cookie Consent Services**

Each service can be individually enabled with its own configuration:

- **Google Tag Manager** - Container ID, Loading Strategy (Strict/Infrastructure)
- **Google Analytics 4** - Measurement ID
- **Facebook Pixel** - Pixel ID
- **Microsoft Clarity** - Project ID
- **Hotjar** - Site ID
- **Matomo** - Tracker URL, Site ID

How It Works
------------

[](#how-it-works)

### Google Consent Mode v2

[](#google-consent-mode-v2)

The module implements Google Consent Mode v2:

```
// Set BEFORE GTM loads
gtag('consent', 'default', {
  'analytics_storage': 'denied',
  'ad_storage': 'denied',
  // ...
});

// When user grants consent
gtag('consent', 'update', {
  'analytics_storage': 'granted',
  // ...
});
```

**No GTM configuration changes required** - tags with Consent Mode enabled automatically wait for consent.

### Category to Consent Mode Mapping

[](#category-to-consent-mode-mapping)

CategoryGoogle Consent Modenecessary`security_storage: granted`analytics`analytics_storage`marketing`ad_storage`, `ad_user_data`, `ad_personalization`preferences`functionality_storage`, `personalization_storage`### GTM Loading Strategies

[](#gtm-loading-strategies)

**Strict Mode (default):**

- GTM is blocked until analytics consent is given

**Infrastructure Mode:**

- GTM loads immediately
- Consent state is pushed to dataLayer
- GTM tags should use Consent Mode or consent-based triggers

Extending the Module
--------------------

[](#extending-the-module)

### XML Configuration

[](#xml-configuration)

Categories, services, and cookies are configured via `cookie_consent.xml`. Create this file in your module's `etc/` directory:

```

        Social Media
        Enable social media integrations
        false
        50

        Custom Tracking
        Our custom analytics service
        analytics
        Vendor_Module::services/custom.phtml
        false

                Custom tracking ID
                1 year

```

### Service Template Example

[](#service-template-example)

Create a template that respects consent blocking:

```
