Skip to main content

Ads and pixels

Microsoft UET

Configure Microsoft UET

Copy your UET tag ID from Microsoft Advertising. Remove the UET snippet and any tag-manager entry that loads the same tag, because the helper creates the uetq queue and constructs UET itself.

npm install @c15t/integrations@alpha
src/consent-scripts.ts
import { microsoftUet } from '@c15t/integrations/microsoft-uet';

export const scripts = [microsoftUet({ id: 'YOUR_UET_TAG_ID' })];

Register the scripts

Complete your framework quickstart first. Keep its Inth endpoint, policy, styles and consent UI. Remove the vendor's original script, SDK initializer or tag-manager entry, so the vendor loads only through c15t.

The vendor pages put the helper in src/consent-scripts.ts. If your framework quickstart already has a scripts array, such as the one in c15t.config.ts in the Next.js guide, add the helper to that array instead of creating a second file. The scripts export is a configuration, not an initializer. Add it to the c15t provider you already have, at the registration point for your framework below. These are edits to that provider, not a second provider.

Add the configuration to scripts in c15t.config.ts, next to next.config.ts:

import { defineConsentConfig } from 'c15t/next';
import { scripts } from './src/consent-scripts';

export default defineConsentConfig({ scripts });

Keep the rest of your config, such as mode and routePrefix, in the same call. ConsentRoot reads the config in the browser, so the layout keeps passing only state. App Router, Pages Router and static export all read the same file. See Next.js scripts and embeds.

Options

OptionDefaultBehavior
idRequiredUET tag ID, passed to UET as ti. The helper trims it. Empty or whitespace-only values log an error and the script does not load.
scriptSrc//bat.bing.com/bat.jsLoader URL override. A blank value falls back to the default.

Loading and revocation

microsoftUet uses the marketing category and alwaysLoad, so bat.js loads on every page whether or not marketing is allowed. Before the script loads, the helper calls uetq.push('consent', 'default', { ad_storage }) with granted or denied from the current marketing permission. After bat.js loads, it constructs UET with enableAutoSpaTracking: true and pushes pageLoad. This is consent signaling, not a request gate. Microsoft's consent mode decides what UET does while ad_storage is denied.

The helper never removes UET. When marketing changes, it calls uetq.push('consent', 'update', { ad_storage }) with the new value. Automatic SPA tracking sends page loads on client-side navigation, so do not push pageLoad from your router.

Verify Microsoft UET

  1. In a private window with an opt-in policy, load the page. The bat.js request goes to bat.bing.com before you choose, and UET sends its page load.
  2. Click Reject, then reload. bat.js still loads, and the page starts with ad_storage denied.
  3. Open Privacy settings and allow marketing. No second bat.js request appears, because the helper sends a consent update to the running tag instead of reloading it.
  4. Navigate to another route in a single-page app. UET sends one page load for the route change, not two.
  5. Turn marketing off again and save. c15t reloads the page, and the new page starts with ad_storage denied.

See the consent verification guide for navigation and hosting checks.