
BigCommerce: Microsoft UET Consent Mode using native BigCommerce cookie
If you are using Bing/Microsoft Advertising you may have been asked to ensure your site is UET for Consent Mode compliant.
What is Microsoft UET?
Microsoft Universal Event Tracking (UET) helps track conversions and build remarketing audiences in your Microsoft Ads campaigns. It works by placing a lightweight JavaScript snippet on your site, similar to Google Ads tags.
Why Consent Mode Matters
Under GDPR and privacy laws, you must respect user cookie preferences before tracking for advertising or analytics. Consent Mode allows UET to adjust its behavior based on user consent:
-
Consent given: UET tracks conversions and remarketing fully.
-
Consent denied: UET sends cookieless pings to maintain limited measurement without cookies.
This keeps you compliant while retaining valuable ad insights.
Using BigCommerce’s Native Cookie for Consent
BigCommerce automatically sets a cookie named:
bc_consent
Looking at the value of the 'bc_consent' cookie, the default value is 'deny':
%7B%22allow%22%3A%5B%5D%2C%22deny%22%3A%5B2%2C3%2C4%5D%7D
That string is a little tricky to understand, so lets have a look at it when it is URL-Decoded:
{"allow":[],"deny":[2,3,4]}
After Consent is given the cookie value is updated to something like this:
%7B%22allow%22%3A%5B2%2C3%2C4%5D%2C%22deny%22%3A%5B%5D%7D
When URL-decoded it looks like this:
{"allow":[2,3,4],"deny":[]}
Based on this information we can control the output of the Conset Mode code.
Code to use
Add the following code to Storefront > Script Manager > Create Script. Enter something like 'UET Consent - Dynamic' for the Script Name. Select the Placement you prefer. Location is 'All Pages'. The Script Category is 'Essential' and Script Type is 'Script'.
Make sure you include the opening and closing <SCRIPT> tags around the code.
// Initialize UET with default denied on page load
window.uetq = window.uetq || [];
window.uetq.push('consent', 'default', {
'ad_storage': 'denied'
});
// Helper to get cookie value
function getCookie(name) {
const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
return match ? decodeURIComponent(match[2]) : null;
}
// Check consent and update UET
function updateUETConsentBasedOnCookie() {
const consentCookie = getCookie('bc_consent');
let isMarketingAllowed = false;
if (consentCookie) {
try {
const consentData = JSON.parse(consentCookie);
if (Array.isArray(consentData.allow) && consentData.allow.includes(4)) {
isMarketingAllowed = true;
}
} catch (e) {
console.error('Error parsing bc_consent cookie:', e);
}
}
window.uetq = window.uetq || [];
if (isMarketingAllowed) {
window.uetq.push('consent', 'update', {
'ad_storage': 'granted'
});
console.log('UET consent updated: granted');
} else {
window.uetq.push('consent', 'update', {
'ad_storage': 'denied'
});
console.log('UET consent updated: denied');
}
}
// Check immediately on load
updateUETConsentBasedOnCookie();
// Monitor for changes without page reload
let lastConsentValue = getCookie('bc_consent');
setInterval(() => {
const currentConsentValue = getCookie('bc_consent');
if (currentConsentValue !== lastConsentValue) {
updateUETConsentBasedOnCookie();
lastConsentValue = currentConsentValue;
}
}, 1000);
Testing
You can test this by manually changing the bc_consent cookie value in your browser's developer tools, and you should see the consent update in real-time with a console log message.
Conclusion
Adding Microsoft UET Consent Mode with BigCommerce’s native cookie is a fast, privacy-compliant upgrade that preserves your Microsoft Ads measurement while respecting user choices. It keeps your business aligned with evolving privacy regulations without disrupting user experience or requiring complex integrations.