Skip to main content

Microsoft UET + DataGrail Consent

Microsoft UET (Universal Event Tracking) supports Consent Mode, which adjusts how the UET tag stores advertising cookies based on a visitor's consent choice. This guide shows you how to default UET to a denied state and grant it only after the visitor accepts your Marketing category.

How It Works

Microsoft UET Consent Mode reads a single signal, ad_storage. When ad_storage is denied, UET operates without advertising cookies; when it is granted, full conversion tracking resumes. You map this signal to DataGrail's Marketing category so UET respects the visitor's banner choice.

This integration uses DataGrail's callback system as the source of truth for consent. The DG_BANNER_API.categoryEnabled('marketing') method returns true when the visitor has granted Marketing consent and false otherwise.

Configuration

The setup has three parts that must appear in this order in your page source.

Set the Default State

Place this before the UET base tag so the default consent state is set on the first UET beacon:

<script>
window.uetq = window.uetq || [];
window.uetq.push('consent', 'default', {
'ad_storage': 'denied'
});
</script>

Add the UET Base Tag

Add your existing Microsoft UET base tag next, unchanged. You can find it in your Microsoft Advertising account under Tools > UET tag.

Add this script after the base tag. It reads the Marketing category on page load and after every banner choice, then updates ad_storage accordingly:

<script>
window.dgEvent = window.dgEvent || [];
window.uetq = window.uetq || [];

function applyUetConsent() {
var granted = window.DG_BANNER_API.categoryEnabled('marketing');
window.uetq.push('consent', 'update', {
'ad_storage': granted ? 'granted' : 'denied'
});
}

window.dgEvent.push({
event: "initial_preference_callback",
params: applyUetConsent
});
window.dgEvent.push({
event: "preference_callback",
params: applyUetConsent
});
</script>

The initial_preference_callback applies any preference already stored for a returning visitor on page load, and the preference_callback updates ad_storage whenever the visitor makes a new choice in the banner. Reusing one function for both keeps the two states consistent and re-denies ad_storage if a visitor revokes Marketing consent in a later session.

Match Your Category Key

This example uses marketing, the default key for the Marketing category. If your consent project uses a custom key for that category, substitute the exact key in the categoryEnabled call.

 

Need help?
If you have any questions, please reach out to your dedicated Account Manager or contact us at support@datagrail.io.

Disclaimer: The information contained in this message does not constitute as legal advice. We would advise seeking professional counsel before acting on or interpreting any material.