Microsoft Advertising Event Tracking | OpsBlu Docs

Microsoft Advertising Event Tracking

Configure conversion goals and custom event tracking for Microsoft Advertising UET.

Overview

Microsoft Advertising event tracking enables measurement of user actions beyond page views. Custom events track purchases, form submissions, downloads, video plays, and any other meaningful user interactions.

Event Tracking Architecture

UET Event Queue

The uetq (Universal Event Tracking Queue) is a JavaScript array that stores events:

window.uetq = window.uetq || [];
window.uetq.push('event', 'event_name', {
  'event_category': 'category',
  'event_label': 'label',
  'event_value': 123
});

Event Parameters

Parameter Type Required Description
event_category String Optional High-level category (e.g., 'ecommerce', 'engagement')
event_label String Optional Specific descriptor (e.g., 'purchase', 'signup')
event_value Number Optional Numeric value associated with event
revenue_value Number Optional Monetary value for conversion tracking
currency String Optional 3-letter ISO currency code (USD, EUR, GBP, etc.)

Conversion Goal Types

1. Destination URL Goals

Track when users reach specific pages:

Example: Purchase Confirmation

Create Goal in Microsoft Advertising

  1. Navigate to Conversions > Conversion goals
  2. Click Create conversion goal
  3. Select Destination URL
  4. Configure goal:
    • Goal name: Purchase Completion
    • URL condition: URL equals /thank-you
    • Revenue: Variable
    • Count: Unique

No Code Required

Destination URL goals don't require custom event code. UET base tag automatically tracks page URLs.

URL Matching Options

  • URL equals: Exact match (/thank-you)
  • URL contains: Partial match (checkout/success)
  • URL begins with: Prefix match (/thank-you)
  • URL matches regex: Pattern match (^/thank-you.*)

2. Custom Event Goals

Track specific user actions via JavaScript events:

Example: Form Submission

Step 1: Fire Custom Event

// When user submits form
document.getElementById('contact-form').addEventListener('submit', function(e) {
  window.uetq = window.uetq || [];
  window.uetq.push('event', 'form_submission', {
    'event_category': 'lead_generation',
    'event_label': 'contact_form',
    'event_value': 50
  });
});

Step 2: Create Goal in Microsoft Advertising

  1. Navigate to Conversions > Conversion goals
  2. Click Create conversion goal
  3. Select Event
  4. Configure goal:
    • Goal name: Contact Form Submission
    • Event action: form_submission
    • Event category: lead_generation (optional)
    • Event label: contact_form (optional)
    • Revenue: Fixed ($50) or Variable
    • Count: Unique

3. Pages per Session Goals

Track engagement based on page depth:

Example: Engaged Visitors

Create Goal in Microsoft Advertising

  1. Navigate to Conversions > Conversion goals
  2. Click Create conversion goal
  3. Select Pages per visit
  4. Configure goal:
    • Goal name: Highly Engaged Visitor
    • Operator: Greater than or equal to
    • Pages: 5
    • Revenue: $10 (engagement value)

No Code Required

UET automatically tracks page views per session.

4. Duration Goals

Track time spent on site:

Example: Long Sessions

Create Goal in Microsoft Advertising

  1. Navigate to Conversions > Conversion goals
  2. Click Create conversion goal
  3. Select Duration
  4. Configure goal:
    • Goal name: Extended Session
    • Operator: Greater than or equal to
    • Duration: 180 seconds (3 minutes)
    • Revenue: $5 (engagement value)

No Code Required

UET automatically tracks session duration.

Custom Event Implementation Examples

E-commerce Purchase

// Fire on order confirmation page
window.uetq = window.uetq || [];
window.uetq.push('event', 'purchase', {
  'event_category': 'ecommerce',
  'event_label': 'order_complete',
  'revenue_value': 149.99,
  'currency': 'USD'
});

Corresponding Goal Configuration:

  • Goal type: Event
  • Event action: purchase
  • Event category: ecommerce
  • Revenue: Variable
  • Count: Unique

Lead Form Submission

// Fire when form is successfully submitted
function onFormSuccess() {
  window.uetq = window.uetq || [];
  window.uetq.push('event', 'lead', {
    'event_category': 'lead_generation',
    'event_label': 'contact_form',
    'event_value': 75
  });
}

Video Play

// Fire when video starts playing
videoPlayer.on('play', function() {
  window.uetq = window.uetq || [];
  window.uetq.push('event', 'video_start', {
    'event_category': 'engagement',
    'event_label': 'product_demo'
  });
});

Video Completion

// Fire when video finishes
videoPlayer.on('ended', function() {
  window.uetq = window.uetq || [];
  window.uetq.push('event', 'video_complete', {
    'event_category': 'engagement',
    'event_label': 'product_demo',
    'event_value': 25
  });
});

Download

// Fire when user downloads file
document.querySelectorAll('a.download').forEach(function(link) {
  link.addEventListener('click', function(e) {
    var fileName = this.getAttribute('href');
    window.uetq = window.uetq || [];
    window.uetq.push('event', 'download', {
      'event_category': 'engagement',
      'event_label': fileName
    });
  });
});

Add to Cart

// Fire when product added to cart
function addToCart(productId, productName, price) {
  window.uetq = window.uetq || [];
  window.uetq.push('event', 'add_to_cart', {
    'event_category': 'ecommerce',
    'event_label': productName,
    'event_value': price
  });

  // Your add to cart logic
  // ...
}

Newsletter Signup

// Fire when user subscribes to newsletter
function onNewsletterSignup() {
  window.uetq = window.uetq || [];
  window.uetq.push('event', 'newsletter_signup', {
    'event_category': 'lead_generation',
    'event_label': 'footer_form'
  });
}

Phone Call Click

// Fire when user clicks phone number
document.querySelectorAll('a[href^="tel:"]').forEach(function(link) {
  link.addEventListener('click', function() {
    window.uetq = window.uetq || [];
    window.uetq.push('event', 'phone_call', {
      'event_category': 'lead_generation',
      'event_label': 'header_click'
    });
  });
});

Dynamic Revenue Tracking

Variable Revenue Values

Track different conversion values for each transaction:

// Capture order total from your application
var orderTotal = 249.99; // From shopping cart or order object
var orderCurrency = 'USD';

window.uetq = window.uetq || [];
window.uetq.push('event', 'purchase', {
  'revenue_value': orderTotal,
  'currency': orderCurrency
});

Revenue from Data Layer

If using Google Tag Manager data layer:

// After dataLayer.push with transaction data
window.uetq = window.uetq || [];
window.uetq.push('event', 'purchase', {
  'revenue_value': {{DLV - transactionTotal}}, // GTM variable
  'currency': {{DLV - transactionCurrency}}    // GTM variable
});

Revenue from Server-Side Template

For server-rendered pages:

<!-- PHP example -->
<script>
window.uetq = window.uetq || [];
window.uetq.push('event', 'purchase', {
  'revenue_value': <?php echo $order_total; ?>,
  'currency': '<?php echo $order_currency; ?>'
});
</script>
<!-- JavaScript template literal example -->
<script>
window.uetq = window.uetq || [];
window.uetq.push('event', 'purchase', {
  'revenue_value': ${orderTotal},
  'currency': '${orderCurrency}'
});
</script>

GTM Implementation for Events

Create Event Tag in GTM

Step 1: Create Custom HTML Tag

Tag configuration:

<script>
window.uetq = window.uetq || [];
window.uetq.push('event', '{{Event - Action}}', {
  'event_category': '{{Event - Category}}',
  'event_label': '{{Event - Label}}',
  'event_value': {{Event - Value}}
});
</script>

Step 2: Create GTM Variables

Create Data Layer Variables:

  • Variable name: Event - Action → Data Layer Variable: eventAction
  • Variable name: Event - Category → Data Layer Variable: eventCategory
  • Variable name: Event - Label → Data Layer Variable: eventLabel
  • Variable name: Event - Value → Data Layer Variable: eventValue

Step 3: Create Trigger

  • Trigger type: Custom Event
  • Event name: uet_event (or your custom event name)
  • This trigger fires on: All Custom Events

Step 4: Push to Data Layer

In your application code:

// When event occurs
dataLayer.push({
  'event': 'uet_event',
  'eventAction': 'purchase',
  'eventCategory': 'ecommerce',
  'eventLabel': 'order_complete',
  'eventValue': 149.99
});

Purchase Event in GTM

Tag Configuration:

Tag Type: Custom HTML

<script>
window.uetq = window.uetq || [];
window.uetq.push('event', 'purchase', {
  'revenue_value': {{DLV - transactionTotal}},
  'currency': {{DLV - transactionCurrency}}
});
</script>

Trigger: Custom Event = purchase or Page View on /thank-you

Event Tracking Best Practices

1. Event Naming Conventions

Use clear, consistent naming:

Good:

  • purchase, lead, signup, download
  • Use lowercase, underscores for spaces
  • Be specific and descriptive

Bad:

  • conv1, event2, conversion
  • Mixed case, unclear purpose
  • Generic names

2. Fire Events Once Per Action

Prevent duplicate events:

// Bad - fires multiple times on click
button.addEventListener('click', function() {
  window.uetq.push('event', 'signup', {});
  window.uetq.push('event', 'signup', {}); // Duplicate!
});

// Good - fires once
var eventFired = false;
button.addEventListener('click', function() {
  if (!eventFired) {
    window.uetq.push('event', 'signup', {});
    eventFired = true;
  }
});

3. Validate Before Firing

Ensure data exists before pushing events:

// Check if revenue value exists and is valid
if (orderTotal && orderTotal > 0) {
  window.uetq = window.uetq || [];
  window.uetq.push('event', 'purchase', {
    'revenue_value': parseFloat(orderTotal),
    'currency': 'USD'
  });
}

4. Use Unique Conversion Counting

For most conversion goals, set Count to Unique to prevent duplicate conversions from same user:

  • Unique: Count once per user per conversion window (recommended)
  • All: Count every time goal is triggered (use for page views or repeat actions)

5. Test Before Launch

Always test events:

  1. Use UET Tag Helper to verify events fire
  2. Check browser console for errors
  3. Complete test conversion in Microsoft Advertising
  4. Verify conversion appears in reporting (2-4 hours)

Conversion Goal Configuration

Step-by-Step Goal Creation

  1. Navigate to Goals

    • Click Tools > Conversions > Conversion goals
  2. Create New Goal

    • Click Create conversion goal
    • Select goal type (Destination, Event, Duration, or Pages/visit)
  3. Configure Goal Settings

    • Goal name: Descriptive name (e.g., "Purchase - Ecommerce")
    • Scope: Campaign-specific or account-wide
    • Category: Purchase, Lead, Signup, etc.
    • UET tag: Select your UET tag
  4. Set Revenue

    • Fixed value: Same amount for all conversions
    • Variable value: Different amounts per conversion
    • No value: For non-revenue goals
  5. Configure Count

    • Unique: Count once per user
    • All: Count every occurrence
  6. Set Attribution

    • Conversion window: Days after click (1-90 days, default 30)
    • View-through window: Days after ad impression (0-30 days, default 1)
  7. Save Goal

    • Click Save
    • Goal status changes to "Recording" after tag verification

Goal Testing Tool

Use Microsoft Advertising's URL testing tool:

  1. Navigate to conversion goal
  2. Click View details
  3. Click Troubleshooting tab
  4. Enter URL to test
  5. Verify goal triggers correctly

Advanced Event Tracking

E-commerce with Product Data

Track enhanced e-commerce data:

window.uetq = window.uetq || [];
window.uetq.push('event', 'purchase', {
  'revenue_value': 299.98,
  'currency': 'USD',
  'ecomm_prodid': ['SKU123', 'SKU456'],
  'ecomm_pagetype': 'purchase',
  'ecomm_totalvalue': 299.98
});

Parameters:

  • ecomm_prodid: Array of product SKUs purchased
  • ecomm_pagetype: Page type (home, category, product, cart, purchase, other)
  • ecomm_totalvalue: Total order value

Dynamic Remarketing

For dynamic product ads:

// Product page
window.uetq = window.uetq || [];
window.uetq.push('event', '', {
  'ecomm_prodid': 'SKU123',
  'ecomm_pagetype': 'product',
  'ecomm_totalvalue': 49.99
});

// Category page
window.uetq.push('event', '', {
  'ecomm_pagetype': 'category',
  'ecomm_category': 'Electronics > Headphones'
});

// Cart page
window.uetq.push('event', '', {
  'ecomm_prodid': ['SKU123', 'SKU456'],
  'ecomm_pagetype': 'cart',
  'ecomm_totalvalue': 99.98
});

Troubleshooting Events

Event Not Firing

Check 1: UET base tag loaded

// In browser console
console.log(window.uetq);
// Should show array with events

Check 2: Event syntax correct

// Correct syntax
window.uetq.push('event', 'purchase', {'revenue_value': 99.99});

// Wrong - missing 'event' as first parameter
window.uetq.push('purchase', {'revenue_value': 99.99}); // WRONG

Check 3: Use UET Tag Helper

  • Extension should show custom events
  • Verify event name and parameters

Event Firing But Not Converting

Check 1: Goal configuration matches event

  • Event action in goal = event name in code
  • Event category/label match (if specified)

Check 2: Goal is "Recording"

  • Navigate to Conversions > Conversion goals
  • Verify status is "Recording" not "Paused"

Check 3: Conversion window

  • User must click ad before converting
  • Conversion must occur within conversion window (default 30 days)

Revenue Values Not Showing

Check 1: Revenue parameter syntax

// Correct
window.uetq.push('event', 'purchase', {
  'revenue_value': 99.99,  // Correct parameter name
  'currency': 'USD'
});

// Wrong
window.uetq.push('event', 'purchase', {
  'event_value': 99.99  // Wrong - this is not revenue
});

Check 2: Goal configured for variable revenue

  • Goal settings must have Revenue set to Variable

Check 3: Currency code

  • Must be valid 3-letter ISO code (USD, EUR, GBP, etc.)
  • Matches account currency or will be converted

Event Tracking Checklist

  • UET base tag installed on all pages
  • Custom events fire at correct moments
  • Event names are clear and consistent
  • Conversion goals created for each event
  • Revenue values passing correctly (if applicable)
  • Events fire once per user action (no duplicates)
  • UET Tag Helper confirms event tracking
  • Test conversions appear in reporting
  • Goals associated with correct campaigns
  • Conversion counting set to Unique (for most goals)

Next Steps