S2S Integration — Upload revenue to Bing Ads with JavaScript

Find out how to interact with Bing Ads API without an SDK

Photo by Campaign Creators on Unsplash
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<NumberToWords xmlns="http://www.dataaccess.com/webservicesserver/">

I. Getting Started

What you need to get started:

  • Access to the Azure portal
  • A valid Microsoft click id (a unique 32 characters long GUID generated when an ad is clicked)
  • Basic understanding of Postman

II. Create an Offline Conversion Goal

To be able to upload revenue, you first need to create a conversion goal with a unique name. Go to Microsoft Ads platform, open the campaign for which you want to upload revenue, and click on Tools > Conversion tracking > Conversion Goal.

III. Authenticate and get and access token

Every time you send a request to the API, you need to use a short-lived access token (typically expires in 60 minutes).

  • Microsoft identity platform
  • code: the authorization code obtained earlier
  • grant_type: code
  • redirect_uri: https://login.microsoftonline.com/common/oauth2/nativeclient
  • scope: https://ads.microsoft.com/ads.manage offline_access
  • tenant: common
  • refresh_token: your refresh token
  • grant_type: refresh_token
  • redirect_uri: https://login.microsoftonline.com/common/oauth2/nativeclient
  • scope: https://ads.microsoft.com/ads.manage offline_access
  • tenant: common

IV. ApplyOfflineConversions

Now that you have your access token, you can finally interact with Bing Ads API! We are close to making our first revenue upload!

  • SOAPAction: ApplyOfflineConversions
  • CustomerAccountId and CustomerId: you can find it on Microsoft Ads web application’s url when selecting an account: https://ui.ads.microsoft.com/campaign/vnext/overview?cid=CustomerIdHere&aid=CustomerAccountIdHere
    You can also call GetUser and GetAccountInfo to obtain it through an API request.
  • Your developer token: more info here
  • Conversion Name: the name you gave to the conversion goal in Part II
  • Conversion Time: a date and time value (eg: 2021–01–27T15:13:13+00:00). Make sure the date and time value is later than the date and time of the recorded click and is within the conversion window (max 90 days from click).
  • ConversionValue: revenue generated
  • MicrosoftClickId: make sure the click id has been generated from the account id set in the header CustomerAccountId.

Wrapping Up

I hope this article gave you an idea of how to use Bing Ads APIs without an SDK. Do not hesitate to leave a comment if you have a question and I’ll try my best to help you. Otherwise, you can ask a question on Microsoft Developer Forum.

JavaScript Mid-Level Developer, I write blogs to learn and share what I learn.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store