Microsoft Ads - CAPI

📘

This integration is currently in beta. Contact your MetaRouter support team to get started.

What Is Microsoft Ads?

Microsoft Ads is a digital advertising platform that enables businesses to create and manage search, shopping, and audience-based ad campaigns. It provides advanced targeting options, including keyword-based bidding, remarketing, and automated optimizations to improve ad performance. The platform includes tools for budget management, performance tracking, and conversion measurement to help advertisers maximize their return on investment.

Microsoft Ads Conversion API (CAPI) enables advertisers to send web and server-side events directly to Microsoft’s Universal Event Tracking (UET) system. By transmitting data server-to-server, the CAPI improves conversion accuracy and resilience against browser tracking limitations while supporting privacy-compliant measurement.


Product Type: Marketing

Integration Type: Starter Kit & ID Sync

Event Source Type: Web, Mobile Browser, & Mobile App

Event Scope: Full-Funnel Events


Capabilities

  • Sends conversion and engagement data directly to Microsoft Ads via API.
  • Preserves attribution accuracy even when cookies or client scripts are blocked.
  • Supports batch uploads of up to 1000 events per request.
  • Captures identifiers (msclkid, mid) for cross-session tracking and attribution.
  • Transmits hashed user identifiers (email, phone) for privacy-safe matching.
  • Supports page, product, and transaction-level events.

Considerations

  • Always include msclkid for accurate conversion attribution.
  • Store msclkid for up to 90 days to preserve click-to-conversion linkage.
  • Include both IP address and user agent to enhance deduplication accuracy.
  • Hashed email (em) and phone (ph) values must follow SHA-256 format and normalization.
  • All events must include an event type of either pageLoad or custom.
  • Each batch request may include up to 1000 events; invalid data may fail the entire batch.

Limitations

  • Validation errors (400 or 401) result in all batch events being rejected.

Identity Sync

  • Sync Available: Yes
  • Required for Starter Kit: Yes
  • Prerequisites: Client ID needed
  • Documentation: Microsoft Ads Sync

Sync Details

  • The Microsoft Ads sync captures the values of the click ID (msclkid).
  • The msclkid is essential for conversion attribution and is required by Microsoft Ads for accurate conversion tracking.
  • Microsoft Ads requires that msclkid only be mapped to your conversion events within the starter kit. Please do not add the click ID to global mapping; otherwise, Microsoft Ads will consider all events a conversion.
  • The sync generates a mid (pageLoadId) for each page view and attaches it to all related events. Themid is required to properly link events to a session.

Starter Kit Setup Guide

1. Deploy the Microsoft Ads Sync

  • To collect the sync values (e.g., msclkid, mid), you must implement a Microsoft Ads ID sync. Refer to the following documentation to complete the setup: Microsoft Ads - ID Sync Guide.

2. Gather Credentials

  • Ask vendor representatives for the following credentials:
    • UET Tag ID: Found under Conversion Tracking > UET Tags in your Microsoft Ads account. Once you click on a specific tag, you will find the TAG ID in the breadcrumb area:


    • API Token: Obtain from your Microsoft Ads account representative.

3. Add a Microsoft Ads Integration

  • From the integration library, add a Microsoft Ads integration. Then, fill out the Connection Parameters:
Connection ParameterDescription
TAG_IDUnique Microsoft Ads UET Tag ID used for event tracking.
API_TOKENToken used to authenticate and authorize API requests.

4. Configure Event Mapping

  • MetaRouter provides all of the event mappings that Microsoft Ads integrations typically require. You may add custom events, parameters, or mappings in accordance with Microsoft’s API documentation.

5. Deploy to Pipeline

  • In the Pipelines tab, add your Microsoft Ads integration.
  • Select the correct integration revision.
  • Click Add Integration and finalize deployment.

Event Mappings

Global

Global mappings will be applied to all events. If your parameter names do not match the Expected Inputs provided, you will need to overwrite the Inputs provided with your own.

Output KeyDescriptionExpected Input
eventType RequiredString: Type of event (pageLoad or custom).Expression – from input.type
eventTime RequiredInteger: Timestamp in seconds (UTC).Expression – convert RFC3339 timestamp to epoch
pageLoadId * RequiredString: UUID linking page load and custom events. * Required for custom events that follow a pageLoad.context.providers.microsoftAds.mid
eventSourceUrl * RequiredString: Page URL where the event occurred. Required for pageLoad events.context.page.url
userData.msclkid RequiredString: Microsoft Click ID.context.providers.microsoftAds.msclkid
userData.clientIpAddress RequiredString: IP address of the user.context.ip
userData.clientUserAgent RequiredString: Browser user agent string.context.userAgent
userData.anonymousId RecommendedString: Anonymous visitor ID.anonymousId
eventName RecommendedString: Event name or fallback to event type.Expression – input.event or input.type
eventIdString: Unique event ID for deduplication.messageId
pageTitleString: Title of the webpage.context.page.title
referrerUrlString: URL of the referring page.context.page.referrer
userData.externalIdString: Authenticated user ID.userId
userData.emString: SHA-256 hashed normalized email address.Expression – hash traits.email
userData.phString: SHA-256 hashed normalized phone number.Expression – hash traits.phone

Event Specific

Page

Output KeyDescriptionExpected Input
customData.eventLabel RecommendedString: Hardcoded page label. Optional field providing a human-readable description for reporting and debugging; helps distinguish similar events that share the same eventName.Enrichment – 'Lorem ipsum'
customData.pageTypeString: home when path is /, otherwise other.Expression – from context.page.path

Products Searched

Output KeyDescriptionExpected Input
customData.pageTypeString: Indicates search results page.Enrichment – 'searchresults'
customData.eventCategoryString: Event category for search actions.Enrichment – 'search'
customData.searchTermString: Search query entered by user.properties.query

Product List Viewed

Output KeyDescriptionExpected Input
customData.pageTypeString: Indicates category listing page.Enrichment – 'category'
customData.ecommCategoryString: Category viewed by user.properties.category
customData.itemIdsArray: Product IDs or SKUs listed.Expression – map properties.products
customData.itemsArray: Product list {id,name,price,quantity}.Expression – map properties.products

Product Clicked

Output KeyDescriptionExpected Input
customData.pageTypeString: Product context.Enrichment – 'product'
customData.ecommCategoryString: Category of clicked product.properties.category
customData.itemIdsArray: Clicked product ID.Expression – from properties.product_id or sku
customData.itemsArray: Details of clicked product.Expression – build from properties

Product Viewed

Output KeyDescriptionExpected Input
customData.pageTypeString: Indicates product view page.Enrichment – 'product'
customData.ecommCategoryString: Product category viewed.properties.category
customData.itemIdsArray: Product IDs viewed.Expression – from properties.product_id or sku
customData.itemsArray: Product details viewed.Expression – build from properties

Product Added

Output KeyDescriptionExpected Input
customData.pageTypeString: Indicates add-to-cart event.Enrichment – 'product'
customData.ecommCategoryString: Product category added.properties.category
customData.itemIdsArray: Added product IDs.Expression – from properties.product_id or sku
customData.itemsArray: Details of added product(s).Expression – build from properties
customData.valueFloat: Total value of added items.Expression – TOTAL_VALUE(properties)
customData.ecommTotalValueFloat: Event total value.Expression – TOTAL_VALUE(properties)
customData.currencyString: ISO 4217 currency code.properties.currency (uppercase, default USD)

Product Removed

Output KeyDescriptionExpected Input
customData.pageTypeString: Product context for removal.Enrichment – 'product'
customData.ecommCategoryString: Product category removed.properties.category
customData.itemIdsArray: Removed product IDs.Expression – from properties.product_id or sku
customData.itemsArray: Details of removed product(s).Expression – build from properties
customData.valueFloat: Value removed from cart.Expression – TOTAL_VALUE(properties)
customData.ecommTotalValueFloat: Total cart value after removal.Expression – TOTAL_VALUE(properties)
customData.currencyString: ISO 4217 currency code.properties.currency (uppercase, default USD)

Cart Viewed

Output KeyDescriptionExpected Input
customData.pageTypeString: Indicates cart page view.Enrichment – 'cart'
customData.itemIdsArray: Product IDs in cart.Expression – map properties.products
customData.itemsArray: Item details {id,name,price,quantity}.Expression – map properties.products
customData.valueFloat: Total cart value.Expression – TOTAL_VALUE(properties.products)
customData.ecommTotalValueFloat: Total cart value (duplicate for reporting).Expression – TOTAL_VALUE(properties.products)
customData.currencyString: ISO 4217 currency code.properties.currency (uppercase, default USD)

Order Completed

Output KeyDescriptionExpected Input
customData.transactionId RequiredString: Unique order ID.properties.order_id
customData.pageTypeString: Indicates purchase confirmation.Enrichment – 'purchase'
customData.itemIdsArray: Purchased product IDs.Expression – map properties.products
customData.itemsArray: Purchased item details.Expression – map properties.products
customData.valueFloat: Total order value.Expression – TOTAL_VALUE(properties.products)
customData.ecommTotalValueFloat: Total order value (duplicate for reporting).Expression – TOTAL_VALUE(properties.products)
customData.currencyString: ISO 4217 currency code.properties.currency (uppercase, default USD)


Required & Recommended Identifiers

These identifiers must be mapped to Microsoft Ads in order for successful user matching to occur. Without these IDs, any events sent to Microsoft Ads may not be accurately reflected in reporting.

AttributeExampleSync Injector Required?
msclkid Requireddd4afcccb1c9a4cad9544dd7e5006Yes
mid Requiredbcf3000b-65fa-4cd2-808a-8a6cf2b1d0a5Yes
anonymousIdb171a9b06ce011ecafcd1b209be8601bYes
externalId111222No
email_hash Recommendede1a2b3c4d5e6f7...No
phone_hash Recommendedc59475d96e9f01d7...No

Integration Validation

Use the UET Tag Dashboard in your Microsoft Advertising account to verify that server-side events are being received successfully. You can also access UET reports within the platform to review event delivery, troubleshoot discrepancies, and validate conversion tracking.


Additional Microsoft Ads Documentation