Export (0) Print
Expand All

Getting the Estimated Position By Bid

This page has been deprecated and the content will not be refreshed as of February 2013.

Instead please see Ad Intelligence Service Reference, Researching and Pricing Keywords, or Bing Ads API Overview.

To get the estimated position in the search results if the specified keywords use the specified bid value, call the GetEstimatedPositionByKeywords or GetEstimatedPositionByKeywordIds operation. You can use the estimated position, clicks, average cost per click (CPC), and impressions that the keywords could generate based on the bid price to determine if you need to bid more or less to achieve the desired position and whether the cost of landing in that position is worth the possible traffic it could generate.

The difference between the two operations is that GetEstimatedPositionByKeywords factors in how well the keyword performed among all advertisers in the specified publisher countries, while GetEstimatedPositionByKeywordIds factors in how well the keyword performed in the ad group.

The following example shows how to call the GetEstimatedPositionByKeywordIds operation.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

// BingAds.AdIntelligence is the application-defined namespace that 
// this example uses for the Ad Intelligence service reference. 

using GetEstimatedPosition.BingAds.AdIntelligence;


namespace GetEstimatedPosition
{
    class Program
    {
        private static AdIntelligenceServiceClient service = null;

        // Specify your credentials.

        private static string m_password = "<passwordgoeshere>";
        private static string m_username = "<usernamegoeshere>";
        private static string m_token = "<devtokengoeshere>";

        // Specify the advertiser's account ID.

        private static long m_accountId = <accountidgoeshere>;


        static void Main()
        {
            KeywordIdEstimatedPosition[] positions = null;

            try
            {
                service = new AdIntelligenceServiceClient();

                positions = GetPositions(m_accountId);

                if (positions != null)
                {
                    foreach (KeywordIdEstimatedPosition position in positions)
                    {
                        if (null == position)
                        {
                            Console.WriteLine("The keyword ID is not valid.");
                        }
                        else
                        {
                            Console.WriteLine("{0} ({1})", position.KeywordEstimatedPosition.Keyword, position.KeywordId);

                            foreach (EstimatedPositionAndTraffic positionByMatchType in position.KeywordEstimatedPosition.EstimatedPositions)
                            {
                                Console.WriteLine("  " + positionByMatchType.MatchType);
                                Console.WriteLine("    Estimated Position: {0}", 
                                    positionByMatchType.EstimatedAdPosition);
                                Console.WriteLine("    Average CPC: " + 
                                    positionByMatchType.AverageCPC);
                                Console.WriteLine("    Estimated clicks per week: {0} to {1}", 
                                    positionByMatchType.MinClicksPerWeek, 
                                    positionByMatchType.MaxClicksPerWeek);
                                Console.WriteLine("    Estimated impressions per week: {0} to {1}", 
                                    positionByMatchType.MinImpressionsPerWeek, 
                                    positionByMatchType.MaxImpressionsPerWeek);
                                Console.WriteLine("    Estimated cost per week: {0} to {1}\n", 
                                    positionByMatchType.MinTotalCostPerWeek, 
                                    positionByMatchType.MaxTotalCostPerWeek);
                            }
                        }
                    }
                }

                service.Close();
            }
            catch (CommunicationException e)
            {
                Console.WriteLine(e.Message);

                if (null != e.InnerException)
                {
                    Console.WriteLine("\n" + e.InnerException.Message);
                }

                if (service != null)
                {
                    service.Abort();
                }
            }
            catch (TimeoutException e)
            {
                Console.WriteLine(e.Message);

                if (service != null)
                {
                    service.Abort();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

                if (service != null)
                {
                    service.Abort();
                }
            }
        }


        // Get the estimated position in the search results if you bid the specified amount. 

        static KeywordIdEstimatedPosition[] GetPositions(long accountId)
        {
            GetEstimatedPositionByKeywordIdsRequest request = new GetEstimatedPositionByKeywordIdsRequest();
            GetEstimatedPositionByKeywordIdsResponse response = null;

            // Set the header information.

            request.CustomerAccountId = accountId.ToString();
            request.DeveloperToken = m_token;
            request.UserName = m_username;
            request.Password = m_password;

            // Set the request information.

            request.KeywordIds = new long[] { <keywordid1>, <keywordid2>, <etc.> };
            request.MaxBid = 0.47;

            try
            {
                response = service.GetEstimatedPositionByKeywordIds(request);
            }
            catch (FaultException<AdApiFaultDetail> fault)
            {
                // Log this fault.

                Console.WriteLine("GetEstimatedPositionByKeywordIds failed with the following faults:\n");

                foreach (AdApiError error in fault.Detail.Errors)
                {
                    if (105 == error.Code) //  InvalidCredentials
                    {
                        Console.WriteLine("The specified credentials are not valid or the account is inactive.");
                    }
                    else
                    {
                        Console.WriteLine("Error code: {0} ({1})\nMessage: {2}\nDetail: {3}\n",
                            error.ErrorCode, error.Code, error.Message, error.Detail);
                    }
                }

            }
            catch (FaultException<ApiFaultDetail> fault)
            {
                // Log this fault.

                Console.WriteLine("GetEstimatedPositionByKeywordIds failed with the following faults:\n");

                foreach (OperationError error in fault.Detail.OperationErrors)
                {
                    switch (error.Code)
                    {
                        case 106: //  UserIsNotAuthorized
                            Console.WriteLine("The user is not authorized to call this operation.");
                            break;

                        case 1515: // CampaignServiceBidAmountsLessThanFloorPrice
                            Console.WriteLine("The bid amount cannot be less than the minimum bid amount allowed for the account's currency.");
                            break;

                        case 1516: // CampaignServiceBidAmountsGreaterThanCeilingPrice
                            Console.WriteLine("The bid amount cannot be greater than the maximum bid amount allowed for the account's currency.");
                            break;

                        case 1529: // CampaignServiceKeywordIdsArrayShouldNotBeNullOrEmpty
                            Console.WriteLine("The list of keyword IDs cannot be null or empty.");
                            break;

                        default:
                            Console.WriteLine("Error code: {0} ({1})\nMessage: {2}\nDetail: {3}\n",
                                error.ErrorCode, error.Code, error.Message, error.Details);
                            break;
                    }
                }

                foreach (BatchError error in fault.Detail.BatchErrors)
                {
                    Console.WriteLine("Error code: {0} ({1})\nIndex: {2}\nMessage: {3}\nDetail: {4}\n",
                        error.ErrorCode, error.Code, error.Index, error.Message, error.Details);
                }

            }

            return (null == response) ? null : response.KeywordEstimatedPositions;
        }
    }
}
Show:
© 2014 Microsoft