How to Install the Microsoft UET Tag | OpsBlu Docs

How to Install the Microsoft UET Tag

Step-by-step UET tag installation for Microsoft Advertising via direct embed, GTM, or tag manager deployment methods.

Delivery Options

Create UET Tag

Before implementation, generate your UET tag in Microsoft Advertising:

Step 1: Navigate to UET Tags

  1. Sign in to Microsoft Advertising
  2. Click Tools in top menu
  3. Select UET tag under Tracking section

Step 2: Create New Tag

  1. Click Create UET tag button
  2. Enter Tag name (e.g., "Main Website Tag")
  3. (Optional) Enter Tag description
  4. Click Save

Step 3: Copy Tag Code

Microsoft Advertising generates a unique tag code:

<script>
(function(w,d,t,r,u){
  var f,n,i;
  w[u]=w[u]||[],f=function(){
    var o={ti:"TAG_ID_HERE"};
    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>

Tag ID: The unique identifier (e.g., 12345678) appears in the tag code as ti:"TAG_ID_HERE"

Direct Embed Implementation

Add UET tag to the <head> section of your HTML, before the closing </head> tag:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Your Website</title>

  <!-- Microsoft Advertising UET Tag -->
  <script>
  (function(w,d,t,r,u){
    var f,n,i;
    w[u]=w[u]||[],f=function(){
      var o={ti:"12345678"}; // Your unique tag ID
      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>
  <!-- End UET Tag -->

</head>
<body>
  <!-- Your page content -->
</body>
</html>

Alternative Placement

UET tag can also be placed before the closing </body> tag, though <head> placement is recommended for earlier data collection:

<!DOCTYPE html>
<html>
<head>
  <title>Your Website</title>
</head>
<body>
  <!-- Your page content -->

  <!-- Microsoft Advertising UET Tag (Alternative Placement) -->
  <script>
  (function(w,d,t,r,u){
    // ... tag code here ...
  })(window,document,"script","//bat.bing.com/bat.js","uetq");
  </script>

</body>
</html>

Implementation Notes

  • Tag loads asynchronously (won't block page rendering)
  • Should be on every page of your website
  • Only one UET tag needed per website
  • Same tag used for conversion tracking, remarketing, and analytics

Google Tag Manager Deployment

Step 1: Create Custom HTML Tag

  1. Sign in to Google Tag Manager
  2. Click Tags in left sidebar
  3. Click New button
  4. Click tag configuration area
  5. Select Custom HTML tag type

Step 2: Configure Tag

  1. Tag name: "Microsoft Advertising - UET Base Tag"
  2. HTML: Paste your complete UET tag code
  3. Tag firing options:
    • Select Support document.write (usually not needed)
    • Ensure Once per page is checked

Step 3: Set Trigger

  1. Click Triggering section
  2. Select All Pages trigger
  3. Click Save

Step 4: Test and Publish

  1. Click Preview button in top right
  2. Navigate to your website in the preview tab
  3. Verify tag fires on all pages using Tag Assistant
  4. If working correctly, click Submit to publish
  5. Add version name and description
  6. Click Publish

Complete GTM Configuration Example

Tag Configuration:

  • Tag Type: Custom HTML
  • Tag Name: Microsoft Advertising - UET Base Tag
  • HTML:
<script>
(function(w,d,t,r,u){
  var f,n,i;
  w[u]=w[u]||[],f=function(){
    var o={ti:"12345678"}; // Replace with your tag ID
    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>

CMS-Specific Implementation

WordPress

Option 1: Theme Header/Footer Editor

  1. Go to Appearance > Theme File Editor
  2. Select header.php
  3. Paste UET tag before </head>
  4. Click Update File

Option 2: WordPress Plugin

  1. Install plugin like "Insert Headers and Footers" or "Head, Footer and Post Injections"
  2. Navigate to plugin settings
  3. Paste UET tag in "Scripts in Header" section
  4. Save changes

Option 3: Google Tag Manager Plugin

  1. Install "Google Tag Manager for WordPress" plugin
  2. Enter GTM container ID in plugin settings
  3. Add UET tag to GTM container (see GTM deployment above)

Shopify

  1. Go to Online Store > Themes
  2. Click Actions > Edit code
  3. Open theme.liquid file
  4. Paste UET tag before </head>
  5. Click Save

Note: UET tag will automatically appear on all pages after saving.

Wix

  1. Go to Settings > Tracking & Analytics
  2. Click + New Tool > Custom
  3. Paste UET tag code
  4. Select All Pages under "Add Code to Pages"
  5. Choose Head for placement
  6. Click Apply

Squarespace

  1. Go to Settings > Advanced > Code Injection
  2. Paste UET tag in Header section
  3. Click Save

Note: Header injection adds code to all pages automatically.

Magento

  1. Navigate to Content > Design > Configuration
  2. Select your store view
  3. Expand HTML Head section
  4. Paste UET tag in Scripts and Style Sheets field
  5. Click Save Configuration

Drupal

  1. Install "Google Tag Manager" module (can be used for any tag manager code)
  2. Or use "Custom JavaScript" module
  3. Navigate to module configuration
  4. Paste UET tag code
  5. Select "Add to all pages"
  6. Save configuration

Server-Side Tagging Implementation

For advanced implementations using Google Tag Manager Server-Side:

Step 1: Set Up Server Container

  1. Create server-side GTM container
  2. Deploy to Cloud Run, App Engine, or custom server
  3. Configure server-side client

Step 2: Create Microsoft Advertising Server Tag

  1. In server container, create Custom tag
  2. Use Microsoft Advertising API endpoint
  3. Map event data from client to server
  4. Include MSCLKID parameter for attribution

Note: Server-side UET implementation requires custom development. Microsoft does not provide official server-side tag template yet.

Benefits of Server-Side Tagging

  • Reduced client-side JavaScript
  • Enhanced data privacy and control
  • Server-side event validation
  • Bypass ad blockers (partially)
  • Lower page weight

Considerations

  • Requires backend development expertise
  • Additional infrastructure costs
  • More complex debugging
  • Attribution may require additional configuration

Validation Checklist

After implementing UET tag, verify:

  • Tag appears in HTML source on all pages
  • No JavaScript errors in browser console
  • Network request to bat.bing.com/bat.js returns 200 OK
  • UET Tag Helper extension detects tag (see Testing section below)
  • Tag ID matches Microsoft Advertising account
  • Tag appears as "Verified" in Microsoft Advertising (within 24 hours)
  • Only one UET tag per page (no duplicates)

Testing with UET Tag Helper

Install Extension

  1. Open Chrome Web Store
  2. Search for "UET Tag Helper"
  3. Click Add to Chrome
  4. Confirm installation

Verify Tag Installation

  1. Navigate to your website
  2. Click UET Tag Helper extension icon in browser toolbar
  3. Look for green checkmark and tag ID
  4. Verify page URL is captured
  5. Check that no errors are displayed

Tag Helper Status Indicators

  • Green checkmark: Tag detected and firing correctly
  • Yellow warning: Tag detected with warnings (e.g., multiple tags)
  • Red X: Tag not detected or critical error

Troubleshooting Installation

Tag Not Loading

Check 1: HTML Source

  • View page source (Ctrl+U or Cmd+U)
  • Search for "bat.bing.com"
  • Verify tag code is present

Check 2: Browser Console

  • Open DevTools (F12)
  • Look for JavaScript errors
  • Check if Content Security Policy (CSP) is blocking

Check 3: Network Tab

  • Open DevTools > Network tab
  • Filter by "bat.bing.com"
  • Verify request is sent and returns 200 status

Tag Not Verified in Microsoft Advertising

Wait time: Microsoft takes up to 24 hours to verify tags

Common issues:

  • Tag only on localhost or staging (must be on public URL)
  • Website requires authentication
  • Robots.txt blocking Microsoft crawler
  • Tag removed or modified after initial verification

Solution: Check tag is on publicly accessible page and wait 24 hours

Multiple Tags Detected

Issue: UET tag loaded more than once on page

Causes:

  • Hardcoded tag + GTM tag
  • Tag in multiple GTM tags
  • Theme and plugin both adding tag

Solution: Remove duplicate implementations, use GTM for centralized management

Content Security Policy Errors

Error: Refused to load the script 'https://bat.bing.com/bat.js'

Solution: Add to CSP header:

Content-Security-Policy: script-src 'self' https://bat.bing.com;

Or in HTML meta tag:

<meta http-equiv="Content-Security-Policy"
      content="script-src 'self' https://bat.bing.com;">

Post-Installation Steps

After successful UET tag installation:

  1. Create conversion goals - Navigate to Conversions in Microsoft Advertising
  2. Set up remarketing audiences - Use UET data for audience targeting
  3. Enable auto-tagging - Append MSCLKID to destination URLs
  4. Test conversions - Complete test transactions to verify tracking
  5. Monitor tag health - Regularly check UET tag status in Microsoft Advertising

Migration from Legacy Tracking

If upgrading from older Microsoft Advertising tracking:

From Old Universal Event Tracking

  1. Create new UET tag in interface
  2. Deploy new tag alongside old tag temporarily
  3. Verify both tags firing with UET Tag Helper
  4. Monitor conversions for 1-2 weeks
  5. Remove old tag once confident new tag working

From Microsoft Conversion Tracking (Deprecated)

  1. Note conversion IDs from old tracking
  2. Create equivalent conversion goals with UET
  3. Deploy UET tag to all pages
  4. Create new conversion goals in Microsoft Advertising
  5. Archive old conversion tracking after migration

Important: Keep old tracking for 30 days during transition for attribution window.

Security Best Practices

  • Use HTTPS protocol for bat.bing.com requests
  • Don't modify Microsoft-provided UET tag code
  • Store tag configuration in version control
  • Limit access to tag management tools (GTM, CMS)
  • Regularly audit tag implementation
  • Use Tag Manager for easier updates and rollbacks

Performance Optimization

  • UET tag loads asynchronously by default
  • Average impact: under 50ms page load time
  • Loads in parallel with other resources
  • Consider using GTM for centralized tag management
  • Defer non-critical conversion events to reduce initial page weight

Next Steps

After installing UET tag:

  1. Configure event tracking for custom conversions
  2. Set up data layer for revenue tracking
  3. Implement cross-domain tracking if needed
  4. Create remarketing audiences in Microsoft Advertising
  5. Enable automated bidding strategies