IntegrationsAdvertisingMicrosoft Ads CAPI

Microsoft Ads CAPI

Datafly Signal delivers conversion events to Microsoft Advertising server-to-server using the Conversions API (formerly Bing Ads). This enables accurate conversion tracking for Bing, Edge, and Microsoft Audience Network campaigns without depending on the UET tag client-side script.

Prerequisites

Before configuring Microsoft Ads CAPI in Signal, you need a Microsoft Advertising account, a UET tag, conversion goals, and an OAuth access token. Follow the steps below to set everything up.

Step 1: Create a Microsoft Advertising Account

If you don’t already have one:

  1. Go to ads.microsoft.com and click Sign up now.
  2. Sign in with your Microsoft account (or create one).
  3. Enter your business information, time zone, and currency.
  4. Complete the account setup wizard.
  5. Note your Customer ID and Account ID from the account settings page (gear icon > Accounts & Billing > Accounts).

Microsoft Advertising uses two separate IDs: the Customer ID (identifies your organization) and the Account ID (identifies the specific ad account). Both are required for the Conversions API.

Step 2: Create a UET Tag

A Universal Event Tracking (UET) tag is required to associate server-side conversions with your ad account.

  1. In Microsoft Advertising, go to Tools > UET tags.
  2. Click Create UET tag.
  3. Give the tag a name (e.g. “Datafly Signal UET”) and optionally a description.
  4. Click Save.
  5. Note the UET Tag ID (numeric) from the tag list.
⚠️

You do not need to install the UET tag JavaScript on your website. Signal delivers events server-side. However, the UET tag must exist in your account as it serves as the container for conversion goals.

Step 3: Set Up Conversion Goals

Conversion goals define the actions you want to track and optimise for.

  1. In Microsoft Advertising, go to Tools > Conversion tracking > Conversion goals.
  2. Click Create conversion goal.
  3. Select the goal type (e.g. Purchase, Lead, Sign-up, Custom).
  4. Choose Event tag as the tracking method and select your UET tag.
  5. Configure the goal settings:
    • Goal name — descriptive name (e.g. “Purchase”, “Lead Form Submit”)
    • Revenue — set to variable revenue for purchase events, or fixed for leads
    • Attribution window — default is 30-day click-through
  6. Click Save.
  7. Repeat for each conversion action you want to track.

Step 4: Generate an OAuth Access Token

Microsoft Ads API uses OAuth 2.0 via the Microsoft Identity Platform (Azure AD).

  1. Go to the Azure Portal > Azure Active Directory > App registrations.
  2. Click New registration.
  3. Enter a name (e.g. “Datafly Signal”), select the supported account type, and set the redirect URI.
  4. Click Register. Note the Application (client) ID.
  5. Go to Certificates & secrets > New client secret. Note the secret value.
  6. Go to API permissions > Add a permission > APIs my organization uses.
  7. Search for Microsoft Ads and add the user_impersonation permission.
  8. Initiate an OAuth 2.0 flow to obtain an access token:
    curl -X POST https://login.microsoftonline.com/common/oauth2/v2.0/token \
      -d "grant_type=authorization_code&client_id=YOUR_CLIENT_ID&client_secret=YOUR_SECRET&code=AUTH_CODE&redirect_uri=YOUR_REDIRECT_URI&scope=https://ads.microsoft.com/msads.manage"
  9. Note the access_token and refresh_token from the response.
⚠️

Microsoft Ads access tokens expire after 1 hour. You must provide a refresh token for automatic renewal. Signal will handle token refresh automatically when refresh_token, oauth_client_id, and oauth_client_secret are configured.

Configure in Signal

Now that you have your Customer ID, Account ID, UET Tag ID, and access token, configure the integration in Signal.

Configuration Fields

FieldRequiredDescription
customer_idYesYour Microsoft Advertising Customer ID. Found under Account Settings.
account_idYesYour Microsoft Advertising Account ID. Found under Account Settings.
access_tokenYesOAuth 2.0 access token with Microsoft Ads API permissions.
uet_tag_idYesYour Universal Event Tracking tag ID. Found under Tools > UET tags.
refresh_tokenNoOAuth refresh token for automatic token renewal. Strongly recommended.
oauth_client_idNoAzure AD Application (client) ID. Required if using refresh token.
oauth_client_secretNoAzure AD client secret. Required if using refresh token.

Management UI Setup

  1. Go to Integrations > Add Integration > Microsoft Ads CAPI.
  2. Enter your customer_id, account_id, and uet_tag_id.
  3. Enter your access_token (and optionally refresh_token with OAuth credentials).
  4. Select consent categories (typically advertising).
  5. Click Save.

Management API Setup

curl -X POST http://localhost:8084/v1/admin/integrations \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "source_id": "src_abc123",
    "vendor": "microsoft_ads",
    "name": "Microsoft Ads CAPI",
    "enabled": true,
    "config": {
      "customer_id": "123456789",
      "account_id": "987654321",
      "access_token": "your_access_token",
      "uet_tag_id": "12345678"
    },
    "consent_categories": ["advertising"]
  }'

API Endpoint

POST https://bingads.microsoft.com/api/v13/offline-conversions

Events are sent as JSON with authentication via the Authorization: Bearer header and the DeveloperToken header.

Identity Signals

Microsoft Ads uses multiple identity signals to match server events to ad clicks and user sessions.

Automatic Signals

These are sent automatically by Signal — no configuration needed:

SignalFieldDescription
msclkidclick_idMicrosoft click ID. Automatically captured from the msclkid URL parameter when a user clicks a Microsoft ad. This is the primary attribution signal.
uet_sessionsession_idUET session identifier. Used for session-level attribution when click ID is not available.
ip_addressForwarded from original requestVisitor’s IP address.
user_agentForwarded from original requestVisitor’s User-Agent string.

When a user clicks a Microsoft ad, the msclkid parameter is appended to the landing page URL:

https://example.com/landing?msclkid=abc123def456ghi789

Datafly.js automatically captures the msclkid from the URL and persists it as a first-party cookie for the duration of the attribution window.

⚠️

The msclkid parameter is essential for conversion attribution. Ensure Auto-tagging is enabled in your Microsoft Advertising account (Account Settings > Auto-tagging). Without it, click IDs will not be appended to your URLs.

User-Provided Signals (Hashed)

When user data is available via _df.identify(), the following fields are SHA-256 hashed before sending to Microsoft:

SignalHashingDescription
hashed_emailSHA-256, lowercase, trimmedUser’s email address
hashed_phoneSHA-256, E.164 formatUser’s phone number

All PII hashing is performed server-side by the Delivery Worker. Raw PII never leaves your infrastructure. Enhanced matching via hashed email and phone improves conversion attribution for users who cannot be matched by click ID alone.

Event Mapping

Datafly EventMicrosoft Ads EventNotes
page (page view)PageViewSent for every page view
Order Completed / Product PurchasedPurchaseRequires revenue, currency
Product AddedAddToCartIncludes item details
Checkout StartedBeginCheckoutIncludes revenue, currency
Product ViewedViewContentIncludes item details
Lead GeneratedLeadLead form submission
Signed UpSignUpUser registration
Products SearchedSearchIncludes search_string
Custom eventsPassed throughSent as custom event name mapped to conversion goal

Example: Purchase Event

Datafly.js call:

_df.track("Order Completed", {
  order_id: "ORD-001",
  total: 129.99,
  currency: "USD",
  products: [
    { product_id: "SKU-A", name: "Widget", price: 49.99, quantity: 2 },
    { product_id: "SKU-B", name: "Gadget", price: 30.01, quantity: 1 }
  ]
});

Microsoft Ads CAPI payload sent by Signal:

{
  "customer_id": "123456789",
  "account_id": "987654321",
  "uet_tag_id": "12345678",
  "event_type": "Purchase",
  "event_time": "2024-01-29T12:00:00Z",
  "event_id": "evt_abc123def456",
  "click_id": "abc123def456ghi789",
  "revenue": 129.99,
  "currency_code": "USD",
  "transaction_id": "ORD-001",
  "page_url": "https://example.com/checkout/confirmation",
  "user_agent": "Mozilla/5.0 ...",
  "ip_address": "203.0.113.50"
}

Testing Your Integration

Step 1: Enable UET Tag Helper

  1. Install the UET Tag Helper browser extension from the Microsoft Edge Add-ons store (also available for Chrome).
  2. Navigate to your website and trigger events.
  3. The extension will show whether UET events are being received (note: this only validates client-side tags, but can confirm your conversion goals are configured correctly).

Step 2: Verify via Signal Event Debugger

  1. Trigger events on your website with the Signal integration enabled.
  2. Open the Signal event debugger to confirm events are being delivered.
  3. Verify the delivery status shows 200 OK responses from Microsoft.

Step 3: Check in Microsoft Advertising

  1. In Microsoft Advertising, go to Tools > Conversion tracking > Conversion goals.
  2. Check the Tracking status column — it should show “Recording conversions” or “Tag active”.
  3. Click on individual goals to see conversion counts. Allow up to 4 hours for data to appear.

Microsoft Advertising may take up to 4 hours to reflect conversion events in the dashboard. If events are not appearing after 6 hours, check the troubleshooting section below.

Troubleshooting

ProblemSolution
Events not appearing in Microsoft AdsVerify customer_id, account_id, and uet_tag_id are correct. Check the access token is valid and has the required permissions.
401 Unauthorized errorsThe access token has expired (1-hour lifetime). Configure a refresh token for automatic renewal.
403 Forbidden errorsThe Azure AD app lacks the user_impersonation permission, or the user does not have access to the ad account.
Conversion goal shows “Unverified”The UET tag has not received any events yet. Send a test event and wait up to 4 hours.
msclkid not being capturedEnsure auto-tagging is enabled in Microsoft Advertising account settings. Check that Datafly.js is loaded on the landing page.
Duplicate conversionsEnsure you are sending a unique event_id with each event. Microsoft deduplicates based on this field.
Revenue not appearing on goalsVerify that total or value and currency are included in event properties. Check the conversion goal is set to variable revenue.

Rate Limits

SettingDefault
rate_limit_rps50
rate_limit_burst100