Export (0) Print
Expand All

C# Examples for Bing Ads

The C Sharp code examples for Bing Ads are developed and run within the environment described in Getting Started Using C# and Visual Basic with Bing Ads Services. Your custom configuration may vary. You may choose to begin with the getting started section, and the remaining examples are grouped by the core scenarios described in Bing Ads Technical Guides.

Getting Started

This example demonstrates how to get your customer and account identifiers. Customer and account identifiers are required for many Bing Ads service operations. For related information, see Getting Started With the Bing Ads API and Customer Management Service Reference.

Topic

Description

Example Operations

Get SOAP Header Elements in C#

This example demonstrates how to get your customer and account identifiers.

GetCustomersInfo

GetAccountsInfo

Managing Customer Accounts

These examples demonstrate how to manage customers, accounts, and users. For related information, see Managing Customer Accounts and Customer Management Service Reference.

Topic

Description

Example Operations

Add User in C#

Add a user within a customer.

AddUser

Delete Account in C#

Inactivate an account.

GetAccount

DeleteAccount

Delete User in C#

Delete a customer’s user.

GetUser

DeleteUser

Manage Accounts in C#

Get, update, and delete a customer’s account.

GetAccountsInfo

GetAccount

UpdateAccount

DeleteAccount

Manage Customers in C#

Get details about a list of customers to which a user has access.

GetCustomersInfo

GetCustomer

UpdateCustomer

Manage Users in C#

Add, get, update, and delete a customer’s user.

AddUser

GetUsersInfo

GetUser

UpdateUser

DeleteUser

Sign Up Customer in C#

Create a new reseller managed customer.

SignupCustomer

Update Account in C#

Get an account and update some elements.

GetAccount

UpdateAccount

Update Customer in C#

Get a customer and update some elements.

GetCustomer

UpdateCustomer

Update User in C#

Get a user and update some elements. Additionally, update the user role.

GetUser

UpdateUser

UpdateUserRoles

Managing Campaigns and Ad Groups

These examples demonstrate how to manage core advertising entities including campaigns and ad groups. For related information, see Managing Campaigns and Ad Groups and Campaign Management Service Reference.

Topic

Description

Example Operations

Add Ad Groups in C#

Create ad groups within a campaign.

AddAdGroups

Add Campaigns in C#

Create campaigns within an account.

AddCampaigns

Ad Rotation in C#

Get and set the ad rotation that an ad group uses.

GetAdRotationByAdGroupIds

SetAdRotationToAdGroups

Get Campaigns in C#

Get campaigns within an account.

GetCampaignsByAccountId

Negative Keywords in C#

Set and get an ad group’s negative keywords.

SetNegativeKeywordsToAdGroups

GetNegativeKeywordsByAdGroupIds

Submit an Ad Group for Approval in C#

Submit an ad group for editorial approval.

SubmitAdGroupForApproval

Update Ad Groups in C#

Update ad groups within a campaign.

UpdateAdGroups

Update Campaigns in C#

Update campaigns within an account.

UpdateCampaigns

Managing Ads and Keywords

These examples demonstrate how to setup and manage text or mobile ads, and bid on keywords. For related information, see Managing Ads and Keywords and Campaign Management Service Reference.

Topic

Description

Example Operations

Ad Extensions in C#

Add extensions to an account’s ad extension library, get extensions from the library, associate the extensions with a campaign, get the extensions that are associated with a campaign, and determine why an extension failed editorial review.

For more information, see Ad Extensions.

AddAdExtensions

GetAdExtensionsByIds

SetAdExtensionsToCampaigns

GetAdExtensionsByCampaignIds

GetAdExtensionEditorialReasonsByCampaignIds

Add Ads in C#

Create ads within an ad group.

AddAds

Get Ad Extensions from Library in C#

Get the IDs of the extensions in the account's extension library. Then use the IDs to get the extensions and print them.

GetAdExtensionIdsByAccountId

GetAdExtensionsByIds

Keywords in C#

Create a keyword, set the keyword's destination URL, and get the keyword and destination URL. If the keyword is disapproved, this example also shows how to get the reasons of why it failed editorial review.

AddKeywords

SetDestinationUrlToKeywords

GetKeywordsByIds

GetDestinationUrlByKeywordIds

GetEditorialReasonsByIds

Product Ads in C#

Add a product extension and associate it with a campaign, add product criterion to an ad group, get and update the criterion, and add promotional text to product ads.

For more information, see Product Ads.

AddAds

AddAdExtensions

AddAdGroupCriterions

GetAdGroupCriterionsByAdGroupId

GetAdGroupCriterionsByIds

SetAdExtensionsToCampaigns

UpdateAdGroupCriterions

Update Ads in C#

Update ads within an ad group.

UpdateAds

Update Keywords in C#

Get specific keywords and update some elements.

GetKeywordsByIds

UpdateKeywords

Managing Targets

These examples demonstrate how to target your ads to display to users of a certain age group, display on certain days of the week, or display to users in a particular geographical area. For related information, see Managing Targets and Campaign Management Service Reference.

Topic

Description

Example Operations

Exclude Locations from a Location Target in C#

Exclude locations from a location target.

GetExclusionsByAssociatedEntityIds

SetExclusionsToAssociatedEntities

Target Ad Groups in C#

Add a target to a customer’s library, and assign the target to an ad group.

AddTargetsToLibrary

SetTargetToAdGroup

Target Age and Gender in C#

Create age and gender targets and add the combined target to a customer’s library.

AddTargetsToLibrary

Target Days and Hours in C#

Create day and hour targets and add the combined target to a customer’s library.

AddTargetsToLibrary

Target Devices in C#

Target specific devices and operating systems.

GetDeviceOSTargetsByIds

GetTargetsByCampaignIds

GetTargetsByIds

UpdateDeviceOSTargets

UpdateTargetsInLibrary

Target Metropolitan Areas in C#

Create a target for a specific metropolitan area, and add it to a customer’s library.

AddTargetsToLibrary

Update Targets in Library in C#

Update an existing target within a customer’s library.

GetTargetsByIds

UpdateTargetsInLibrary

Downloading Campaigns

These examples demonstrate how to download campaign data in bulk in the background. For related information, see Downloading Campaigns and Bulk Service Reference.

Topic

Description

Example Operations

Download Campaigns in C#

Download the entities of one or more campaigns in the background.

DownloadCampaignsByCampaignIds

GetDownloadStatus

Optimizing Campaigns

These examples demonstrate how to discover opportunities to improve your ads' performance and increase your return on investment. For related information, see Optimizing Campaigns and Optimizer Service Reference.

Topic

Description

Example Operations

Optimize Bids in C#

Get the bid opportunities which have not expired for the specified account.

GetBidOpportunities

ApplyOpportunities

Optimize Budget in C#

Get the budget opportunities which have not expired for the specified account.

GetBudgetOpportunities

ApplyOpportunities

Managing Editorial Review and Appeals

These examples demonstrate how to determine whether ads or keywords passed or failed the review. For related information, see Managing Editorial Review and Appeals and Campaign Management Service Reference.

Topic

Description

Example Operations

Editorial Review and Appeals in C#

Find keywords that have been editorially rejected, print the reasons for the rejections, and then appeal the rejections.

GetKeywordsByEditorialStatus

GetEditorialReasonsByIds

AppealEditorialRejections

Getting Reports

These examples demonstrate how to get detailed reports about accounts, campaigns, and ad groups. The information can help you track finances, measure performance, and adjust settings to optimize your budget or campaign. For related information, see Getting Reports and Reporting Service Reference.

Topic

Description

Example Operations

Keyword Performance Report in C#

Request and retrieve a keyword performance report.

SubmitGenerateReport

PollGenerateReport

Researching and Pricing Keywords

These examples demonstrate how to manage customers, accounts, and users. For related information, see Researching and Pricing Keywords and Ad Intelligence Service Reference.

Topic

Description

Example Operations

Get Historical Performance in C#

Get the historical bid and traffic performance of one or more keywords used in search queries.

GetHistoricalKeywordPerformanceByDevice

Get Estimated Bid By Position in C#

Get the minimum suggested bid value of one or more keywords that could result in an ad appearing in the targeted position in the search results.

GetEstimatedBidByKeywords

Get Estimated Position By Bid in C#

Get the estimated position in the search results if the specified keywords use the specified bid value.

GetEstimatedPositionByKeywordIds

Get Keyword Suggestions in C#

Get keyword suggestions that could perform better than the specified keywords.

SuggestKeywordsFromExistingKeywords

Get Keyword Search Count in C#

Get a count of the number of search queries that included the specified keywords.

GetHistoricalSearchCountByDevice

Get User Demographics in C#

Get the age and gender of users who have searched for specific keywords.

GetKeywordDemographics

Get User Locations in C#

Get the geographical location of users who have searched for specific keywords.

GetKeywordLocations

Handling Service Errors and Exceptions

These examples demonstrate how to handle service errors and exceptions. For related information, see Handling Service Errors and Exceptions and Bing Ads API Error Codes.

Topic

Description

Example Errors

Accessing the Fault Details in C#

Handle Bing Ads campaign management service fault exceptions.

AdApiFaultDetail

AnalyticsApiFaultDetail

ApiFaultDetail

EditorialApiFaultDetail

Exception Handling in C#

This example shows how to catch Windows Communication Foundation (WCF) exceptions.

CommunicationException

TimeoutException

Exception

Community Additions

Show:
© 2014 Microsoft