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:
- Go to ads.microsoft.com and click Sign up now.
- Sign in with your Microsoft account (or create one).
- Enter your business information, time zone, and currency.
- Complete the account setup wizard.
- 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.
- In Microsoft Advertising, go to Tools > UET tags.
- Click Create UET tag.
- Give the tag a name (e.g. “Datafly Signal UET”) and optionally a description.
- Click Save.
- 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.
- In Microsoft Advertising, go to Tools > Conversion tracking > Conversion goals.
- Click Create conversion goal.
- Select the goal type (e.g. Purchase, Lead, Sign-up, Custom).
- Choose Event tag as the tracking method and select your UET tag.
- 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
- Click Save.
- 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).
- Go to the Azure Portal > Azure Active Directory > App registrations.
- Click New registration.
- Enter a name (e.g. “Datafly Signal”), select the supported account type, and set the redirect URI.
- Click Register. Note the Application (client) ID.
- Go to Certificates & secrets > New client secret. Note the secret value.
- Go to API permissions > Add a permission > APIs my organization uses.
- Search for Microsoft Ads and add the
user_impersonationpermission. - 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" - Note the
access_tokenandrefresh_tokenfrom 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
| Field | Required | Description |
|---|---|---|
customer_id | Yes | Your Microsoft Advertising Customer ID. Found under Account Settings. |
account_id | Yes | Your Microsoft Advertising Account ID. Found under Account Settings. |
access_token | Yes | OAuth 2.0 access token with Microsoft Ads API permissions. |
uet_tag_id | Yes | Your Universal Event Tracking tag ID. Found under Tools > UET tags. |
refresh_token | No | OAuth refresh token for automatic token renewal. Strongly recommended. |
oauth_client_id | No | Azure AD Application (client) ID. Required if using refresh token. |
oauth_client_secret | No | Azure AD client secret. Required if using refresh token. |
Management UI Setup
- Go to Integrations > Add Integration > Microsoft Ads CAPI.
- Enter your
customer_id,account_id, anduet_tag_id. - Enter your
access_token(and optionallyrefresh_tokenwith OAuth credentials). - Select consent categories (typically
advertising). - 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-conversionsEvents 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:
| Signal | Field | Description |
|---|---|---|
msclkid | click_id | Microsoft click ID. Automatically captured from the msclkid URL parameter when a user clicks a Microsoft ad. This is the primary attribution signal. |
uet_session | session_id | UET session identifier. Used for session-level attribution when click ID is not available. |
ip_address | Forwarded from original request | Visitor’s IP address. |
user_agent | Forwarded from original request | Visitor’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=abc123def456ghi789Datafly.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:
| Signal | Hashing | Description |
|---|---|---|
hashed_email | SHA-256, lowercase, trimmed | User’s email address |
hashed_phone | SHA-256, E.164 format | User’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 Event | Microsoft Ads Event | Notes |
|---|---|---|
page (page view) | PageView | Sent for every page view |
Order Completed / Product Purchased | Purchase | Requires revenue, currency |
Product Added | AddToCart | Includes item details |
Checkout Started | BeginCheckout | Includes revenue, currency |
Product Viewed | ViewContent | Includes item details |
Lead Generated | Lead | Lead form submission |
Signed Up | SignUp | User registration |
Products Searched | Search | Includes search_string |
| Custom events | Passed through | Sent 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
- Install the UET Tag Helper browser extension from the Microsoft Edge Add-ons store (also available for Chrome).
- Navigate to your website and trigger events.
- 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
- Trigger events on your website with the Signal integration enabled.
- Open the Signal event debugger to confirm events are being delivered.
- Verify the delivery status shows
200 OKresponses from Microsoft.
Step 3: Check in Microsoft Advertising
- In Microsoft Advertising, go to Tools > Conversion tracking > Conversion goals.
- Check the Tracking status column — it should show “Recording conversions” or “Tag active”.
- 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
| Problem | Solution |
|---|---|
| Events not appearing in Microsoft Ads | Verify customer_id, account_id, and uet_tag_id are correct. Check the access token is valid and has the required permissions. |
401 Unauthorized errors | The access token has expired (1-hour lifetime). Configure a refresh token for automatic renewal. |
403 Forbidden errors | The 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 captured | Ensure auto-tagging is enabled in Microsoft Advertising account settings. Check that Datafly.js is loaded on the landing page. |
| Duplicate conversions | Ensure you are sending a unique event_id with each event. Microsoft deduplicates based on this field. |
| Revenue not appearing on goals | Verify that total or value and currency are included in event properties. Check the conversion goal is set to variable revenue. |
Rate Limits
| Setting | Default |
|---|---|
rate_limit_rps | 50 |
rate_limit_burst | 100 |
For full API documentation, see Microsoft Ads Universal Event Tracking documentation.