GetHistoricalSearchCount Service Operation - Ad Insight

Gets the number of times the normalized term was used in a search during the specified time period. The results are aggregated by device type.

Request Elements

The GetHistoricalSearchCountRequest 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 search counts for the device types that you specify only, if available.
string array
EndDate The end date of the date range that identifies the data that you want to use to determine the historical search count.

The date cannot be later than today's date, and must be later than or the same as the specified start date.

The effective end date may be adjusted if the specified TimePeriodRollup is Weekly or Monthly.
DayMonthAndYear
Keywords An array of keywords for which you want to determine the number of times that the keyword was used in a search query. 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.
string
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
StartDate The start date of the date range that identifies the data that you want to use to determine the historical search count.

This date must be earlier than or the same as the specified end date. The date should be later than the maximum available historical data range corresponding to the specified TimePeriodRollup element.

The effective start date may be adjusted if the specified TimePeriodRollup is Weekly or Monthly.
DayMonthAndYear
TimePeriodRollup You may specify whether to return data aggregated daily, weekly, or monthly.

For a list of supported values, see the Remarks section below.
string

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 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

Note

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 GetHistoricalSearchCountResponse 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
KeywordSearchCounts An array of KeywordSearchCount data objects. The array contains an item for each keyword specified in the request. If the keyword is not valid, the corresponding item in the array will be null.

Each KeywordSearchCount contains an array of SearchCountsByAttributes. The array contains an item for each unique device specified in the request.
KeywordSearchCount 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="Microsoft.Advertiser.AdInsight.Api.Service.V12">
    <Action mustUnderstand="1">GetHistoricalSearchCount</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>
    <GetHistoricalSearchCountRequest xmlns="Microsoft.Advertiser.AdInsight.Api.Service.V12">
      <Keywords i:nil="false" xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <a1:string>ValueHere</a1:string>
      </Keywords>
      <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>
      <StartDate xmlns:e93="http://schemas.datacontract.org/2004/07/Microsoft.BingAds.Advertiser.AdInsight.Api.DataContract.V12.Entity" i:nil="false">
        <e93:Day>ValueHere</e93:Day>
        <e93:Month>ValueHere</e93:Month>
        <e93:Year>ValueHere</e93:Year>
      </StartDate>
      <EndDate xmlns:e94="http://schemas.datacontract.org/2004/07/Microsoft.BingAds.Advertiser.AdInsight.Api.DataContract.V12.Entity" i:nil="false">
        <e94:Day>ValueHere</e94:Day>
        <e94:Month>ValueHere</e94:Month>
        <e94:Year>ValueHere</e94:Year>
      </EndDate>
      <TimePeriodRollup i:nil="false">ValueHere</TimePeriodRollup>
      <Devices i:nil="false" xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <a1:string>ValueHere</a1:string>
      </Devices>
    </GetHistoricalSearchCountRequest>
  </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="Microsoft.Advertiser.AdInsight.Api.Service.V12">
    <TrackingId d3p1:nil="false" xmlns:d3p1="http://www.w3.org/2001/XMLSchema-instance">ValueHere</TrackingId>
  </s:Header>
  <s:Body>
    <GetHistoricalSearchCountResponse xmlns="Microsoft.Advertiser.AdInsight.Api.Service.V12">
      <KeywordSearchCounts xmlns:e95="http://schemas.datacontract.org/2004/07/Microsoft.BingAds.Advertiser.AdInsight.Api.DataContract.V12.Entity" d4p1:nil="false" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">
        <e95:KeywordSearchCount>
          <e95:Keyword d4p1:nil="false">ValueHere</e95:Keyword>
          <e95:SearchCountsByAttributes d4p1:nil="false">
            <e95:SearchCountsByAttributes>
              <e95:Device d4p1:nil="false">ValueHere</e95:Device>
              <e95:HistoricalSearchCounts d4p1:nil="false">
                <e95:HistoricalSearchCountPeriodic>
                  <e95:SearchCount>ValueHere</e95:SearchCount>
                  <e95:DayMonthAndYear d4p1:nil="false">
                    <e95:Day>ValueHere</e95:Day>
                    <e95:Month>ValueHere</e95:Month>
                    <e95:Year>ValueHere</e95:Year>
                  </e95:DayMonthAndYear>
                </e95:HistoricalSearchCountPeriodic>
              </e95:HistoricalSearchCounts>
            </e95:SearchCountsByAttributes>
          </e95:SearchCountsByAttributes>
        </e95:KeywordSearchCount>
      </KeywordSearchCounts>
    </GetHistoricalSearchCountResponse>
  </s:Body>
</s:Envelope>

Code Syntax

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

public async Task<GetHistoricalSearchCountResponse> GetHistoricalSearchCountAsync(
	IList<string> keywords,
	string language,
	IList<string> publisherCountries,
	DayMonthAndYear startDate,
	DayMonthAndYear endDate,
	string timePeriodRollup,
	IList<string> devices)
{
	var request = new GetHistoricalSearchCountRequest
	{
		Keywords = keywords,
		Language = language,
		PublisherCountries = publisherCountries,
		StartDate = startDate,
		EndDate = endDate,
		TimePeriodRollup = timePeriodRollup,
		Devices = devices
	};

	return (await AdInsightService.CallAsync((s, r) => s.GetHistoricalSearchCountAsync(r), request));
}
static GetHistoricalSearchCountResponse getHistoricalSearchCount(
	ArrayOfstring keywords,
	java.lang.String language,
	ArrayOfstring publisherCountries,
	DayMonthAndYear startDate,
	DayMonthAndYear endDate,
	java.lang.String timePeriodRollup,
	ArrayOfstring devices) throws RemoteException, Exception
{
	GetHistoricalSearchCountRequest request = new GetHistoricalSearchCountRequest();

	request.setKeywords(keywords);
	request.setLanguage(language);
	request.setPublisherCountries(publisherCountries);
	request.setStartDate(startDate);
	request.setEndDate(endDate);
	request.setTimePeriodRollup(timePeriodRollup);
	request.setDevices(devices);

	return AdInsightService.getService().getHistoricalSearchCount(request);
}
static function GetHistoricalSearchCount(
	$keywords,
	$language,
	$publisherCountries,
	$startDate,
	$endDate,
	$timePeriodRollup,
	$devices)
{

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

	$request = new GetHistoricalSearchCountRequest();

	$request->Keywords = $keywords;
	$request->Language = $language;
	$request->PublisherCountries = $publisherCountries;
	$request->StartDate = $startDate;
	$request->EndDate = $endDate;
	$request->TimePeriodRollup = $timePeriodRollup;
	$request->Devices = $devices;

	return $GLOBALS['AdInsightProxy']->GetService()->GetHistoricalSearchCount($request);
}
response=adinsight_service.GetHistoricalSearchCount(
	Keywords=Keywords,
	Language=Language,
	PublisherCountries=PublisherCountries,
	StartDate=StartDate,
	EndDate=EndDate,
	TimePeriodRollup=TimePeriodRollup,
	Devices=Devices)

Remarks

The following case-sensitive values may be specified, and data will be returned as far back as the corresponding maximum available historical data range.

TimePeriodRollup Available Historical Data
Daily Up to 45 days prior to the most recent completed day.
Weekly Up to 15 weeks prior to the most recent completed week.

The specified StartDate is adjusted back to the nearest Sunday, and the EndDate is adjusted forward to the nearest Saturday.
Monthly Up to 24 months prior to the most recent completed month.

The specified StartDate is adjusted back to the beginning of the month, and the EndDate is adjusted forward to the end of the month.

Requirements

Service: AdInsightService.svc v12
Namespace: Microsoft.Advertiser.AdInsight.Api.Service.V12