Skip to content

Setting up the Bing Ads API

Registering the application

First we need a Microsoft developer account so we can register an application. Most of the process is defined in this blog by Microsoft. We can follow that link to register an application. Set up the redirect uri to http://localhost:8041/api/integrations/bing/callback as we are using that for bing ads api callback.

Be extra aware of the application secret, application id (or Client id) and the developer token. Copy them somewhere as we will be using them later.

Configuring the backend:

These tokens are specified in the settings.py as :

BING_ADS_CLIENT_ID = # 'YOUR CLIENT/APPLICATION ID GOES HERE'
BING_ADS_CLIENT_SECRET = # 'YOUR CLIENT SECRET/ PASSWORD GOES HERE'
BING_ADS_DEV_TOKEN = # 'YOUR DEVELOPER TOKEN GOES HERE'

We also specify the redirect uri, bing's version, and two other variables for the app in settings.py as:

BING_FILE_FORMAT = 'Csv'
BING_ENV = 'production'
BING_ENV_REDIRECT = 'http://localhost:8041/api/integrations/bing/callback'
BING_VERSION = 13

Check if the callback url matches in attribution_backend/backend/api/urls.py and whether there are three url, one for call back, one to initialize and one to fetch account.

#bing
re_path(r'^integrations/bing/callback$', bing_callback, name='bing_callback'),
re_path(r'^(?P<account_token>[0-9a-z-]+)/integrations/bing/initialise/$', bing_init, name='bing_init'),
re_path(r'^(?P<account_token>[0-9a-z-]+)/integrations/bing/fetch-accounts/(?P<connection>[0-9]+)/$', bing_fetch_accounts, name='bing_fetch_accounts'),

Setting up the frontend

In account-configuration.js in react\dash\src\layouts\account-configuration.js you can add the configuration for bing under the Integration account configuration.

It more or less looks like this :

{
    keyValue: 'integrations_bing-api',
    type: 'ComponentListRowTitleCopy',
    title: 'Bing',
    copy: 'Set up and manage integrations from your Bing accounts into the Cubed Platform. Data from Bing is used to supplement the Cubed Tag with keyword and other SEO data.',
    chevron: true,
    onClick: this.listComponentOnClickHandler
}

Testing with the API

We need a Bing ad account. So, when you click on create, after finishing the setting up process you can log into the ad account and import all the data into cubed platform.

create bing ad account