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.
Note
Unless otherwise noted below, all request elements are required.
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. Possible values include Danish, Dutch, English, Finnish, French, German, Italian, Norwegian, Portuguese, Spanish, Swedish, and TraditionalChinese. |
string |
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. The following language and country/region combinations are supported: Danish: DK Dutch: NL English: AU, CA, GB, ID, IN, MY, PH, SG, TH, US, VN Finnish: FI French: CA, FR German: AT, CH, DE Italian: IT Norwegian: NB Portuguese: BR Spanish: AR, CL, CO, ES, MX, PE, VE Swedish: SE TraditionalChinese: HK, TW If this element is null, then by default the service includes 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. Sidebar ads no longer serve on Bing owned and operated sites in the United States. If you only request first page data e.g., FirstPage1 for the United States (US), then the KeywordKPIs element in the result will be nil/empty. If you include additional countries/regions e.g., US and CA in the same request, then any first page results are only attributed to countries/regions outside the United States. |
AdPosition |
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 LastDay. |
TimeInterval |
Request Header Elements
Element | Description | Data Type |
---|---|---|
AuthenticationToken | The OAuth access token that represents the credentials of a user who has permissions to Microsoft Advertising accounts. For more information see Authentication with OAuth. |
string |
CustomerAccountId | The identifier of the ad account that owns or is associated with the entities in the request. This header element must have the same value as the AccountId body element when both are required. This element is required for most service operations, and as a best practice you should always set it. For more information see Get Your Account and Customer IDs. |
string |
CustomerId | The identifier of the manager account (customer) the user is accessing or operating from. A user can have access to multiple manager accounts. This element is required for most service operations, and as a best practice you should always set it. For more information see Get Your Account and Customer IDs. |
string |
DeveloperToken | The developer token used to access the Bing Ads API. For more information see Get a Developer Token. |
string |
Password | This element is reserved for internal use and will be removed from a future version of the API. You must use the AuthenticationToken element to set user credentials. | string |
UserName | This element is reserved for internal use and will be removed from a future version of the API. You must use the AuthenticationToken element to set user credentials. | string |
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
This template was generated by a tool to show the order of the body and header elements for the SOAP request. For supported types that you can use with this service operation, see the Request Body Elements reference above.
<s:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns="https://bingads.microsoft.com/AdInsight/v13">
<Action mustUnderstand="1">GetHistoricalKeywordPerformance</Action>
<AuthenticationToken i:nil="false">ValueHere</AuthenticationToken>
<CustomerAccountId i:nil="false">ValueHere</CustomerAccountId>
<CustomerId i:nil="false">ValueHere</CustomerId>
<DeveloperToken i:nil="false">ValueHere</DeveloperToken>
</s:Header>
<s:Body>
<GetHistoricalKeywordPerformanceRequest xmlns="https://bingads.microsoft.com/AdInsight/v13">
<Keywords i:nil="false" xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a1:string>ValueHere</a1:string>
</Keywords>
<TimeInterval i:nil="false">ValueHere</TimeInterval>
<TargetAdPosition i:nil="false">ValueHere</TargetAdPosition>
<MatchTypes i:nil="false">
<MatchType>ValueHere</MatchType>
</MatchTypes>
<Language i:nil="false">ValueHere</Language>
<PublisherCountries i:nil="false" xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a1:string>ValueHere</a1:string>
</PublisherCountries>
<Devices i:nil="false" xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a1:string>ValueHere</a1:string>
</Devices>
</GetHistoricalKeywordPerformanceRequest>
</s:Body>
</s:Envelope>
Response SOAP
This template was generated by a tool to show the order of the body and header elements for the SOAP response.
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns="https://bingads.microsoft.com/AdInsight/v13">
<TrackingId d3p1:nil="false" xmlns:d3p1="http://www.w3.org/2001/XMLSchema-instance">ValueHere</TrackingId>
</s:Header>
<s:Body>
<GetHistoricalKeywordPerformanceResponse xmlns="https://bingads.microsoft.com/AdInsight/v13">
<KeywordHistoricalPerformances d4p1:nil="false" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">
<KeywordHistoricalPerformance>
<Keyword d4p1:nil="false">ValueHere</Keyword>
<KeywordKPIs d4p1:nil="false">
<KeywordKPI>
<Device d4p1:nil="false">ValueHere</Device>
<MatchType>ValueHere</MatchType>
<AdPosition>ValueHere</AdPosition>
<Clicks>ValueHere</Clicks>
<Impressions>ValueHere</Impressions>
<AverageCPC>ValueHere</AverageCPC>
<CTR>ValueHere</CTR>
<TotalCost>ValueHere</TotalCost>
<AverageBid>ValueHere</AverageBid>
</KeywordKPI>
</KeywordKPIs>
</KeywordHistoricalPerformance>
</KeywordHistoricalPerformances>
</GetHistoricalKeywordPerformanceResponse>
</s:Body>
</s:Envelope>
Code Syntax
The example syntax can be used with Bing Ads SDKs. See Bing Ads API 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();
request.setKeywords(keywords);
request.setTimeInterval(timeInterval);
request.setTargetAdPosition(targetAdPosition);
request.setMatchTypes(matchTypes);
request.setLanguage(language);
request.setPublisherCountries(publisherCountries);
request.setDevices(devices);
return AdInsightService.getService().getHistoricalKeywordPerformance(request);
}
static function GetHistoricalKeywordPerformance(
$keywords,
$timeInterval,
$targetAdPosition,
$matchTypes,
$language,
$publisherCountries,
$devices)
{
$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);
}
response=adinsight_service.GetHistoricalKeywordPerformance(
Keywords=Keywords,
TimeInterval=TimeInterval,
TargetAdPosition=TargetAdPosition,
MatchTypes=MatchTypes,
Language=Language,
PublisherCountries=PublisherCountries,
Devices=Devices)
Requirements
Service: AdInsightService.svc v13
Namespace: https://bingads.microsoft.com/AdInsight/v13
Request Url
https://adinsight.api.bingads.microsoft.com/AdInsight/v13/HistoricalKeywordPerformance/Query
Request Elements
The GetHistoricalKeywordPerformanceRequest object defines the body and header elements of the service operation request.
Note
Unless otherwise noted below, all request elements are required.
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. Possible values include Danish, Dutch, English, Finnish, French, German, Italian, Norwegian, Portuguese, Spanish, Swedish, and TraditionalChinese. |
string |
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. The following language and country/region combinations are supported: Danish: DK Dutch: NL English: AU, CA, GB, ID, IN, MY, PH, SG, TH, US, VN Finnish: FI French: CA, FR German: AT, CH, DE Italian: IT Norwegian: NB Portuguese: BR Spanish: AR, CL, CO, ES, MX, PE, VE Swedish: SE TraditionalChinese: HK, TW If this element is null, then by default the service includes 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. Sidebar ads no longer serve on Bing owned and operated sites in the United States. If you only request first page data e.g., FirstPage1 for the United States (US), then the KeywordKPIs element in the result will be nil/empty. If you include additional countries/regions e.g., US and CA in the same request, then any first page results are only attributed to countries/regions outside the United States. |
AdPosition |
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 LastDay. |
TimeInterval |
Request Header Elements
Element | Description | Data Type |
---|---|---|
Authorization | The OAuth access token that represents the credentials of a user who has permissions to Microsoft Advertising accounts. Please ensure that the token is prefixed with "Bearer ", this is necessary for proper authentication. For more information see Authentication with OAuth. |
string |
CustomerAccountId | The identifier of the ad account that owns or is associated with the entities in the request. This header element must have the same value as the AccountId body element when both are required. This element is required for most service operations, and as a best practice you should always set it. For more information see Get Your Account and Customer IDs. |
string |
CustomerId | The identifier of the manager account (customer) the user is accessing or operating from. A user can have access to multiple manager accounts. This element is required for most service operations, and as a best practice you should always set it. For more information see Get Your Account and Customer IDs. |
string |
DeveloperToken | The developer token used to access the Bing Ads API. For more information see Get a Developer Token. |
string |
Password | This element is reserved for internal use and will be removed from a future version of the API. You must use the AuthenticationToken element to set user credentials. | string |
UserName | This element is reserved for internal use and will be removed from a future version of the API. You must use the AuthenticationToken element to set user credentials. | string |
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 JSON.
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 JSON
This template was generated by a tool to show the body and header elements for the JSON request. For supported types that you can use with this service operation, see the Request Body Elements reference above.
{
"Keywords": [
"ValueHere"
],
"TimeInterval": "ValueHere",
"TargetAdPosition": "ValueHere",
"MatchTypes": [
"ValueHere"
],
"Language": "ValueHere",
"PublisherCountries": [
"ValueHere"
],
"Devices": [
"ValueHere"
]
}
Response JSON
This template was generated by a tool to show the body and header elements for the JSON response.
{
"KeywordHistoricalPerformances": [
{
"Keyword": "ValueHere",
"KeywordKPIs": [
{
"AdPosition": "ValueHere",
"AverageBid": DoubleValueHere,
"AverageCPC": DoubleValueHere,
"Clicks": IntValueHere,
"CTR": DoubleValueHere,
"Device": "ValueHere",
"Impressions": "LongValueHere",
"MatchType": "ValueHere",
"TotalCost": DoubleValueHere
}
]
}
]
}
Code Syntax
To call REST API through SDKs, you need to upgrade SDK to a certain version and configure the system parameters.The example syntax can be used with Bing Ads SDKs. See Bing Ads API 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();
request.setKeywords(keywords);
request.setTimeInterval(timeInterval);
request.setTargetAdPosition(targetAdPosition);
request.setMatchTypes(matchTypes);
request.setLanguage(language);
request.setPublisherCountries(publisherCountries);
request.setDevices(devices);
return AdInsightService.getService().getHistoricalKeywordPerformance(request);
}
static function GetHistoricalKeywordPerformance(
$keywords,
$timeInterval,
$targetAdPosition,
$matchTypes,
$language,
$publisherCountries,
$devices)
{
$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);
}
response=adinsight_service.GetHistoricalKeywordPerformance(
Keywords=Keywords,
TimeInterval=TimeInterval,
TargetAdPosition=TargetAdPosition,
MatchTypes=MatchTypes,
Language=Language,
PublisherCountries=PublisherCountries,
Devices=Devices)