Microsoft Advertising runs on the UET tag, the Universal Event Tracking tag, which works much like the Google tag: a base tag on every page, events pushed from the page, conversion goals defined in the account. Through GTM, it reuses the dataLayer you already have. This guide covers the base tag, event goals with revenue, enhanced conversions and consent.
Step 1: Create the UET Tag
In Microsoft Advertising, open Tools, then Conversion tracking, then UET tags, and create a tag. Copy the tag ID. Keep one UET tag per account unless you have a specific reason for more.
Step 2: Base Tag in GTM
Add the Microsoft Advertising UET template from the Community Template Gallery. Configure it with the tag ID, event type Page load, a consent requirement for ad_storage, and the All Pages trigger plus the consent update event.
Raw snippet for reference:
<script>
(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"YOUR_TAG_ID", enableAutoSpaTracking: true};o.q=w[u],w[u]=new UET(o),w[u].push("pageLoad")},n=d.createElement(t),n.src=r,n.async=1,n.onload=n.onreadystatechange=function(){var s=this.readyState;s&&s!=="loaded"&&s!=="complete"||(f(),n.onload=n.onreadystatechange=null)},i=d.getElementsByTagName(t)[0],i.parentNode.insertBefore(n,i)})(window,document,"script","//bat.bing.com/bat.js","uetq");
</script>
The enableAutoSpaTracking option handles single page app route changes.
Step 3: Event Goals
In Conversion tracking, then Conversion goals, create a goal of type Event. Set the category such as Purchase or Lead, and define the match: event action equals purchase for ecommerce, generate_lead for leads, with revenue from the event's value. Set Count to Unique for leads and All for purchases. Save.
Create one goal per outcome, matching the names you will send.
Step 4: Fire Events From the dataLayer
Create a UET template tag per event with event type Custom, event action set to the goal's action such as purchase, and parameters: event_category, event_label, event_value, plus revenue_value and currency for purchases. Trigger on the dataLayer event. With raw code:
<script>
window.uetq = window.uetq || [];
window.uetq.push('event', 'purchase', {
event_category: 'ecommerce',
event_label: {{dlv - ecommerce.transaction_id}},
revenue_value: {{dlv - ecommerce.value}},
currency: {{dlv - ecommerce.currency}}
});
</script>
For leads:
<script>
window.uetq = window.uetq || [];
window.uetq.push('event', 'generate_lead', {
event_category: 'lead',
event_label: {{dlv - form_name}},
revenue_value: {{LT - lead value}},
currency: 'USD'
});
</script>
Step 5: Enhanced Conversions
In the UET tag settings in Microsoft Advertising, enable enhanced conversions and accept the terms. In GTM, pass the hashed identifiers before the conversion event. The template has fields for email and phone; with raw code:
<script>
window.uetq = window.uetq || [];
window.uetq.push('set', { pid: { em: {{dlv - user_email}}, ph: {{dlv - user_phone}} } });
</script>
The UET script hashes the values. Fire this on the user data dataLayer push and before the conversion event.
Step 6: Consent
Hold the base tag and all event tags until ad_storage is granted through GTM consent settings. Additionally, pass Microsoft's consent signal so the tag behaves correctly if it loads before the choice:
<script>
window.uetq = window.uetq || [];
window.uetq.push('consent', 'default', { ad_storage: 'denied' });
</script>
And on acceptance:
<script>
window.uetq = window.uetq || [];
window.uetq.push('consent', 'update', { ad_storage: 'granted' });
</script>
Fire the default on Consent Initialization and the update on your consent platform's update event.
Step 7: Verify
- Install the UET Tag Helper browser extension. Load the site: the base tag reports a page load with the tag ID.
- GTM Preview: complete a conversion; the event tag fires once with the action and revenue. Inspect the request to bat.bing.com in a tag debugger such as the Insighter Debugger extension.
- In Microsoft Advertising, UET tags page: status Tag active. Conversion goals page: status Recording conversions after a test, usually within a few hours.
- Confirm revenue appears on the purchase goal.
Common Problems
- Tag active, goals unverified. The event action name does not match the goal's definition. Check case and spelling.
- No revenue.
revenue_valuesent as a string or missing; must be a number. - Duplicates. A URL goal and an event goal for the same outcome; archive the URL goal.
- Enhanced conversions not matching. The set call fired after the event, or values unnormalised.
Outcome
Microsoft Advertising gets the same clean conversions as your other platforms, with revenue, hashed identifiers and consent handled, so automated bidding works and the channel can be compared honestly with Google.
