Search by

hryvinskyi / magento2-cookie-consent-microsoft

hryvinskyi

Microsoft UET and Clarity consent for hryvinskyi/magento2-cookie-consent, with Microsoft's known cookies and blocking rules

Package info

github.com/hryvinskyi/magento2-cookie-consent-microsoft

Type:magento2-module

pkg:composer/hryvinskyi/magento2-cookie-consent-microsoft

Statistics

Installs: 2

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.1 2026-12-01 13:06 UTC

This package is auto-updated.

Last update: 2026-12-01 13:08:40 UTC


README

Microsoft UET and Clarity consent for hryvinskyi/magento2-cookie-consent, with Microsoft's known cookies and blocking rules.

What it does for a store

  • Tells both tags the choice. A part of the consent runtime tells the advertising tag (UET) ad_storage through commands pushed onto window.uetq, and the session-analytics tag (Clarity) ad_Storage and analytics_Storage through window.clarity('consentv2', …). The default goes before either tag runs, then the stored consent, then every change. When a visitor withdraws every key after one was granted, Clarity's cookies are erased with window.clarity('consent', false).
  • Two implementations per tag. Advanced (the default): the tag loads with the page and adapts to the consent it is told. Basic: the tag is also held back until its category is allowed, by the blocking rules of its own source — microsoft_uet (the tag's script on bat.bing.com and the inline loader that requests bat.bing.com/bat.js) or microsoft_clarity (the loader on www.clarity.ms/tag/, the library on scripts.clarity.ms and the loader's inline form). Each tag has an implementation and a category of its own; a tag with none set follows the shared ones.
  • Declares Microsoft's first-party names in the consent catalogue of known trackers: _uetsid, _uetvid, _uetmsclkid (cookies, and local storage keys with their _exp companions) and Clarity's _clck, _clsk, _cltk.
  • Two rows in the consent setup wizard's Blocking step, Microsoft Advertising and Microsoft Clarity: a switch between the basic and the advanced implementation and a select for the tag's category. A row shows the shared implementation and category while the tag's own hold none, and is read-only while the module or the tag is switched off.

Requirements

  • hryvinskyi/magento2-cookie-consent and hryvinskyi/magento2-admin-setup-wizard, and the platform's Store and Config modules (what composer.json and etc/module.xml declare). PHP 8.1 or higher.

Installation

composer require hryvinskyi/magento2-cookie-consent-microsoft
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

Configuration

Stores › Configuration › Hryvinskyi Extensions › Cookie Consent › Microsoft Consent (hryvinskyi_cookie_consent/microsoft/*), every field per default, website and store view.

Setting Path Default
Enabled microsoft/enabled on
Advertising tag (UET) used microsoft/uet_enabled on
Session-analytics tag (Clarity) used microsoft/clarity_enabled on
Advertising tag: implementation, category microsoft/uet_mode, microsoft/uet_category empty: the shared ones
Session-analytics tag: implementation, category microsoft/clarity_mode, microsoft/clarity_category empty: the shared ones
Implementation (both tags, unless set per tag) microsoft/mode advanced (basic)
Category that lets the tags load (unless set per tag) microsoft/basic_category marketing
The category ad_storage follows microsoft/ad_storage_category marketing
The category analytics_storage follows microsoft/analytics_storage_category statistics

A value that reaches the configuration without the form and breaks a rule is read as its default. A category the store does not have is never allowed, so its key stays denied.

What it adds to the consent module

All in the global etc/di.xml: the runtime part signal-microsoft (Model\Runtime\MicrosoftSignalPart), the known-tracker source microsoft, the blocking rule sources microsoft_uet and microsoft_clarity (virtual types of Model\Rule\MicrosoftRules, each describing on the Blocking rules page what it does on a store view), and the wizard settings and Blocking-step rows microsoft_uet (address bat.bing.com) and microsoft_clarity (addresses www.clarity.ms and scripts.clarity.ms).

Limits

  • The two queue objects are the only globals the module creates, only for a tag that is on and only when none exists, the way each vendor's snippet does. It loads neither tag itself.
  • In the advanced implementation the tags load before a choice and are told denied; what they send while denied is Microsoft's to decide. Use the basic implementation to keep them off the page.
  • The rules hold back the scripts that load the tags. The vendors' sign-in and dashboard pages and the endpoints the tags send data to are not scripts and have no rule.

Translations

The admin wording ships in en_US and 25 more locales: the official languages of the European Union, Norwegian Bokmål and Ukrainian. The translations are machine-made; have them read by a native speaker before a store relies on them.

Tests

  • Unit: vendor/bin/phpunit -c app/code/Hryvinskyi/CookieConsentMicrosoft/phpunit.xml.dist; the browser part: npm test and npm run check in Test/Js.
  • Integration: the platform's harness in dev/tests/integration.
  • Browser flows: Test/E2e/, run with the @hryvinskyi/magento2-e2e package from the shop's e2e/ directory.