Microsoft Universal Event Tracking (UET) Consent Mode

Last updated on February 12, 2025

Overview

This document outlines a detailed approach to implementing Universal Event Tracking (UET) while adhering to user consent choices. UET is a tracking mechanism used in Microsoft Advertising to collect user interaction data to measure conversions and optimise ad performance. To comply with privacy regulations, UET must execute only when users consent to advertisement cookies.

The document outlines two implementation methods:

Method 1: Implementing via Google Tag Manager (GTM)
Method 2: Implementing via the custom script

Both methods ensure that UET is only loaded after consent is provided through CookieYes.

Prerequisites

  • A Microsoft Advertising account with access to UET.
  • A CookieYes account with an active subscription.
  • A website has implemented both UET and CookieYes.

Universal Event Tracking and How Does It Work

Universal Event Tracking (UET) is a tracking mechanism employed by Microsoft Advertising to collect data on user interactions. This enables businesses to analyse conversions and enhance ad performance. UET works by embedding a tracking script (tag) on a website, which transmits data back to Microsoft Advertising whenever users interact with it. To comply with privacy standards and get user consent, the UET script must be implemented in a way that respects cookie preferences.

UET Consent mode is controlled through a property called ad_storage. The possible values for ad_storage are:

Value for ad_storageDescription
GrantedFirst and Third-party cookies may be read and written for UET. If no default is set, UET uses Granted by default.
DeniedFor UET, first-party cookies are neither read nor written. Third-party cookies are not written and can only be read for fraud detection and spam prevention, not for advertising purposes

By default, Microsoft UET Consent Mode remains enabled, but if you disable it, follow these steps to turn it back on:

  1. Log in to your CookieYes web app account.
  2. Navigate to CookieYes Dashboard > Advanced Settings.
  3. In Advanced Settings, toggle the button (to the right) labelled Support Microsoft UET Consent Mode under the Microsoft consent mode & Clarity API integration section.
Support Microsoft UET Consent Mode

To ensure compliance with privacy regulations, Microsoft Universal Event Tracking (UET) should only activate when users consent to advertisement cookies. CookieYes enables this by managing UET execution based on user preferences.

This section covers two integration methods:

  • Google Tag Manager (GTM): Configuring UET to fire only after users grant consent.
  • Custom Script: Implementing UET dynamically based on consent signals.

By using CookieYes, businesses can track user interactions responsibly while maintaining regulatory compliance and user trust.

Method 1: Implementation Through Google Tag Manager

If you have implemented UET via Google Tag Manager (GTM), you must configure it to fire only after the user has granted consent to advertising cookies to ensure compliance with cookie consent regulations.

Step 1: Add the GTM Script Below the CookieYes Script

To ensure user consent is checked before executing UET, place the Google Tag Manager script after the CookieYes script in your website’s <head> section. This ensures that GTM respects the user’s consent preferences before triggering any tracking scripts.

GTM Script

Step 2: Create a user-defined variable

  1. From the left panel of your GTM account, select Variables > In the User-Defined Variables section, click New.

    Add Variable
  2. Click Variable Configuration. Choose variable type as 1st Party Cookie from under Page Variables.

    Choose variable type

Note

1st Party Cookie variable allows Google Tag Manager to access the first-party cookies created by your website.

cookie consent

Cookies installed by the site — which appear under the Application tab of the Developer console.

  1. In the Cookie Name text box, enter the cookie name for which you need to retrieve the value.
    e.g. cookieyes-consent
  2. Name the variable (here, we’ve named it ‘Advertisement’) and click Save to save the variable.

    Variable

Step 3: Create a Custom Trigger for UET in GTM

To prevent the UET tag from firing only after receiving consent, follow these steps:

  1. Click Trigger Configuration and choose Custom Event as the trigger type.

    Trigger configuration
  2. In the Event Name text box, enter cookie_consent_update as shown below and check the Use regex matching option.

    Event name
  3. Under This trigger fires on, choose Some Custom Events.
  4. Under Fire this trigger when an Event occurs and all of these conditions are true, set up a trigger condition.
    e.g., Advertisement Trigger (i.e. the name of the user-defined variable you created in Step 2), contains, and advertisement:yes (as shown below).

    Trigger Fire
  5. Name the Trigger (we’ve named it ‘Custom UET‘) and click Save to save the custom event trigger.

Step 4: Add the Custom Event Trigger to the UET Tag.

  1. From the left panel of your GTM account, select Tags. Then click the UET Tag name you want to fire.
  2. Under Triggering, click Choose a trigger to make this tag fire and select the custom consent trigger you created Step 3.

    Add Trigger

    Choose Trigger
  3. Now click Save.

Step 5: Submit Changes

  1. Click the Submit button at the top right corner of your GTM account.

    submit
  1. Finally, click Publish to make this tag live on your website.

    publish change

Method 2: Implementation using the Custom Script

If you have implemented UET by installing the UET script in the <head> of your website, you can ensure it runs only when users provide explicit consent for advertisement tracking by using a custom script without the need for Google Tag Manager (GTM).

Caution

Prior to implementing Microsoft Consent Mode through the custom script, ensure the removal of the UET Tag Script from the head tag of your website.

Step 1: Add the Custom Script Below the CookieYes Script

Copy the custom script and paste it below the CookieYes script :

<script>
    function initializeUET() {
        // Paste UET script here
    }
    document.addEventListener('cookieyes_banner_load', (eventData) => {
        const data = eventData.detail;
        if (data.categories.advertisement) initializeUET();
        else document.addEventListener('cookieyes_consent_update', handleConsentUpdate);
    });
    function handleConsentUpdate(eventData) {
        const data = eventData.detail;
        if (data.accepted.includes("advertisement")) initializeUET();
    }
</script>

Step 2: Add the UET script

Place the UET script after removing the Script tags (<script> and </script>) from the code block inside the initializeUET() to ensure it runs only when consent is granted.

UET Script

How do I obtain the UET script?

  1. Log into Microsoft Advertising.
  2. From the left panel, navigate to Conversions > UET tag.
  3. Find the UET tag from the list and locate the View tag.
View tag

Conclusion

Implementing UET while respecting user consent is crucial for compliance with privacy regulations. The two methods above provide a structured approach that enables dynamic tag management and consent-aware tracking, validating consent before executing UET. Following these guidelines helps businesses effectively track user interactions while adhering to privacy standards and maintaining user trust.

Have more questions?

Reach out to us and we'll answer them.

Contact us