GetHistoricalKeywordPerformance Service Operation - Ad Insight

Gets the historical performance of the normalized search term. The results are aggregated by device type.

Request Elements

The GetHistoricalKeywordPerformanceRequest object defines the body and header elements of the service operation request. The elements must be in the same order as shown in the Request SOAP.

Request Body Elements

Element Description Data Type
Devices A list of one or more of the following device types: Computers, NonSmartphones, Smartphones, Tablets. The default is Computers.

The response includes keyword performance data for the device types that you specify only, if available.
Used to determine a keyword's performance on the specified device types.
string array
Keywords An array of keywords for which you want to get historical performance statistics. The array can contain a maximum of 1,000 keywords, and each keyword can contain a maximum of 100 characters. string array
Language The language in which the keywords are written.

The countries/regions that you specify in the PublisherCountries element must support the specified language.

For possible values, see Ad Languages.
MatchTypes The match types for which you want to get historical data.

You may not specify the Content match type.
MatchType array
PublisherCountries The country codes of the countries/regions to use as the source of the historical data.

You can specify one or more country codes. Each country/region that you specify must support the language specified in the Language element.

For possible values, see Geographical Location Codes.

If Null, the default is all countries/regions that support the specified language.
string array
TargetAdPosition The position of the search results for which you want to get performance data.

For example, to get performance data when ads appeared in the first position of the mainline by using the keyword and match type, set this element to MainLine1. To get performance data when ads appeared in any position of the search results by using the keyword and match type, set this element to All.

The default value is All.

If you specify All for this element, the service will return multiple results per keyword for each supported ad position. If you specify Aggregate, the service will return one aggregated result.
TimeInterval The time period that identifies the data to use to determine the key performance index of the specified keywords. For example, use data from the previous seven days or previous 30 days to determine the keyword performance.

The default value is Last7Days.

Request Header Elements

Element Description Data Type
AuthenticationToken The OAuth access token that represents a Microsoft Account user who has permissions to Bing Ads accounts. string
CustomerAccountId The identifier of the account that owns the entities in the request. This header element must have the same value as the AccountId body element when both are required. string
CustomerId The identifier of the customer that contains and owns the account. If you manage an account of another customer, you should use that customer ID instead of your own customer ID. string
DeveloperToken The developer token used to access the Bing Ads API. string
Password The Bing Ads managed user's sign-in password. string
UserName The Bing Ads managed user's sign-in name. You must not set this element to a Microsoft account or email address. string


The UserName and Password header elements are deprecated. In future versions of the API, Bing Ads will transition exclusively to Microsoft Account (email address) authentication. For more information, see Authentication with OAuth. UserName and Password are still required for Bing Ads managed credentials, but they are not applicable for Microsoft account authentication. To authenticate a Microsoft account, use the AuthenticationToken] header instead of UserName and Password.


The CustomerAccountId and CustomerId are required for most service operations, and as a best practice you should always specify them in the request.

Response Elements

The GetHistoricalKeywordPerformanceResponse object defines the body and header elements of the service operation response. The elements are returned in the same order as shown in the Response SOAP.

Response Body Elements

Element Description Data Type
KeywordHistoricalPerformances An array of KeywordHistoricalPerformance data objects. The array contains an item for each keyword, device, match type, and ad position specified in the request. If the keyword is not valid or has no data available, the corresponding item in the array will be null. KeywordHistoricalPerformance array

Response Header Elements

Element Description Data Type
TrackingId The identifier of the log entry that contains the details of the API call. string

Request SOAP

The following template shows the order of the body and header elements for the SOAP request.

<s:Envelope xmlns:i="" xmlns:s="">
  <s:Header xmlns="Microsoft.Advertiser.AdInsight.Api.Service.V11">
    <Action mustUnderstand="1">GetHistoricalKeywordPerformance</Action>
    <ApplicationToken i:nil="false">ValueHere</ApplicationToken>
    <AuthenticationToken i:nil="false">ValueHere</AuthenticationToken>
    <CustomerAccountId i:nil="false">ValueHere</CustomerAccountId>
    <CustomerId i:nil="false">ValueHere</CustomerId>
    <DeveloperToken i:nil="false">ValueHere</DeveloperToken>
    <Password i:nil="false">ValueHere</Password>
    <UserName i:nil="false">ValueHere</UserName>
    <GetHistoricalKeywordPerformanceRequest xmlns="Microsoft.Advertiser.AdInsight.Api.Service.V11">
      <Keywords i:nil="false" xmlns:a1="">
      <TimeInterval i:nil="false">ValueHere</TimeInterval>
      <TargetAdPosition i:nil="false">ValueHere</TargetAdPosition>
      <MatchTypes i:nil="false">
      <Language i:nil="false">ValueHere</Language>
      <PublisherCountries i:nil="false" xmlns:a1="">
      <Devices i:nil="false" xmlns:a1="">

Response SOAP

The following template shows the order of the body and header elements for the SOAP response.

<s:Envelope xmlns:s="">
  <s:Header xmlns="Microsoft.Advertiser.AdInsight.Api.Service.V11">
    <TrackingId d3p1:nil="false" xmlns:d3p1="">ValueHere</TrackingId>
    <GetHistoricalKeywordPerformanceResponse xmlns="Microsoft.Advertiser.AdInsight.Api.Service.V11">
      <KeywordHistoricalPerformances xmlns:e378="" d4p1:nil="false" xmlns:d4p1="">
          <e378:Keyword d4p1:nil="false">ValueHere</e378:Keyword>
          <e378:KeywordKPIs d4p1:nil="false">
              <e378:Device d4p1:nil="false">ValueHere</e378:Device>

Code Syntax

The example syntax can be used with Bing Ads SDKs. See Bing Ads Code Examples for more examples.

public async Task<GetHistoricalKeywordPerformanceResponse> GetHistoricalKeywordPerformanceAsync(
    IList<string> keywords,
    TimeInterval? timeInterval,
    AdPosition? targetAdPosition,
    IList<MatchType> matchTypes,
    string language,
    IList<string> publisherCountries,
    IList<string> devices)
    var request = new GetHistoricalKeywordPerformanceRequest
        Keywords = keywords,
        TimeInterval = timeInterval,
        TargetAdPosition = targetAdPosition,
        MatchTypes = matchTypes,
        Language = language,
        PublisherCountries = publisherCountries,
        Devices = devices

    return (await AdInsightService.CallAsync((s, r) => s.GetHistoricalKeywordPerformanceAsync(r), request));
static GetHistoricalKeywordPerformanceResponse getHistoricalKeywordPerformance(
    ArrayOfstring keywords,
    TimeInterval timeInterval,
    AdPosition targetAdPosition,
    ArrayOfMatchType matchTypes,
    java.lang.String language,
    ArrayOfstring publisherCountries,
    ArrayOfstring devices) throws RemoteException, Exception
    GetHistoricalKeywordPerformanceRequest request = new GetHistoricalKeywordPerformanceRequest();


    return AdInsightService.getService().getHistoricalKeywordPerformance(request);
static function GetHistoricalKeywordPerformance(

    $GLOBALS['Proxy'] = $GLOBALS['AdInsightProxy'];

    $request = new GetHistoricalKeywordPerformanceRequest();

    $request->Keywords = $keywords;
    $request->TimeInterval = $timeInterval;
    $request->TargetAdPosition = $targetAdPosition;
    $request->MatchTypes = $matchTypes;
    $request->Language = $language;
    $request->PublisherCountries = $publisherCountries;
    $request->Devices = $devices;

    return $GLOBALS['AdInsightProxy']->GetService()->GetHistoricalKeywordPerformance($request);


Service: AdInsightService.svc v11
Namespace: Microsoft.Advertiser.AdInsight.Api.Service.V11