UNPKG

c15t

Version:

Headless JavaScript consent management platform for cookie banners, privacy preferences, consent storage, and script gating.

157 lines (122 loc) 4.78 kB
--- title: Microsoft UET description: Track conversions and measure performance for Microsoft Advertising and Bing Ads. icon: microsoft group: integrations --- Microsoft UET (Universal Event Tracking) is Microsoft's conversion tracking tag for Microsoft Advertising. It tracks user actions, measures campaign effectiveness, and enables remarketing campaigns. ## Official Microsoft documentation * [Universal Event Tracking](https://learn.microsoft.com/en-us/advertising/guides/universal-event-tracking?view=bingads-13) * [UET tag data object](https://learn.microsoft.com/en-us/advertising/campaign-management-service/uettag?view=bingads-13) * [FAQ: Universal Event Tracking](https://help.ads.microsoft.com/#apex/3/en/53056/2) * [FAQ: Remarketing](https://help.ads.microsoft.com/#apex/3/en/56727/1) > 📝 **Note:** > UET can also load Microsoft Clarity (if enabled in your UET tag settings). Since Clarity is an analytics tool, we recommend loading it separately with measurement consent instead. ## Integrate with c15t **React** ```tsx import { type ReactNode } from 'react'; import { ConsentManagerProvider } from '@c15t/react'; import { microsoftUet } from '@c15t/scripts/microsoft-uet'; const scripts = [microsoftUet({ id: '123456789012345' })]; export function ConsentProvider({ children }: { children: ReactNode }) { return ( <ConsentManagerProvider options={{ mode: 'hosted', backendURL: 'https://your-instance.c15t.dev', scripts, }} > {children} </ConsentManagerProvider> ); } ``` **Next.js** ```tsx 'use client'; import { type ReactNode } from 'react'; import { ConsentManagerProvider } from '@c15t/nextjs'; import { microsoftUet } from '@c15t/scripts/microsoft-uet'; const scripts = [microsoftUet({ id: '123456789012345' })]; export function ConsentProvider({ children }: { children: ReactNode }) { return ( <ConsentManagerProvider options={{ mode: 'hosted', backendURL: '/api/c15t', scripts, }} > {children} </ConsentManagerProvider> ); } ``` **JavaScript** ```ts import { getOrCreateConsentRuntime } from 'c15t'; import { microsoftUet } from '@c15t/scripts/microsoft-uet'; getOrCreateConsentRuntime({ mode: 'hosted', backendURL: 'https://your-instance.c15t.dev', scripts: [microsoftUet({ id: '123456789012345' })], }); ``` ## How c15t loads it * **Category:** `marketing` (Ads & Pixels) * **Loads when:** immediately, with Microsoft consent mode enabled * **Default consent:** c15t pushes `ad_storage: 'denied'` before loading UET unless marketing consent is already granted * **On grant/revocation:** c15t pushes the new consent state to `uetq` so UET can switch between granted and denied mode without removing the script Use the UET tag ID as `id`. Microsoft recommends creating one UET tag and adding it across your site; that tag can then support conversion goals and remarketing lists. ## Tracking events in your app c15t loads Microsoft UET in consent mode, so `window.uetq` is created before consent is granted. Your own event calls are **not** automatically gated. Guard them if you only want to send custom conversion events after marketing consent is granted. Microsoft's custom event syntax uses `window.uetq.push('event', action, parameters)`. Conversion goals can match page visits and custom events, and event payloads can include revenue fields such as `revenue_value` and `currency`. ```tsx import { useCallback } from 'react'; import { useConsentManager } from '@c15t/react'; function useTrackPurchase() { const { has } = useConsentManager(); return useCallback(() => { if (has('marketing')) { window.uetq?.push('event', 'purchase', { revenue_value: 10, currency: 'USD', }); } }, [has]); } function CheckoutButton() { const trackPurchase = useTrackPurchase(); return ( <button type="button" onClick={trackPurchase}> Complete purchase </button> ); } ``` ## Types ### MicrosoftUetOptions |Property|Value| |:--|:--| |Type Name|\`MicrosoftUetOptions\`| |Source Path|\`./packages/scripts/src/vendors/ads-and-pixels/microsoft-uet.ts\`| \*ExtractedTypeTable: Could not extract "MicrosoftUetOptions" from "./packages/scripts/src/vendors/ads-and-pixels/microsoft-uet.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\* ### Script |Property|Value| |:--|:--| |Type Name|\`Script\`| |Source Path|\`./packages/core/src/libs/script-loader/types.ts\`| \*ExtractedTypeTable: Could not extract "Script" from "./packages/core/src/libs/script-loader/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*