How i can set Ad Schedule criterion and date range to get Traffic Estimate?

207 views
Skip to first unread message

Qaiser Javed

unread,
Sep 11, 2018, 8:16:17 AM9/11/18
to AdWords API and Google Ads API Forum
Hello,

I am using following code.In this code i want to set ad schedule and date range to get traffic estimation. Ad Schedule because only want to run campaign on Monday accordingly needs traffic estimates for Monday only, and date range because needs traffic estimates for next month October.

using (TrafficEstimatorService trafficEstimatorService =
                (TrafficEstimatorService)user.GetService(
                    AdWordsService.v201806.TrafficEstimatorService))
            {

                // Create keywords. Refer to the TrafficEstimatorService documentation for the maximum
                // number of keywords that can be passed in a single request.
                Keyword keyword1 = new Keyword();
                keyword1.text = "mars cruise";
                keyword1.matchType = KeywordMatchType.BROAD;

                Keyword keyword2 = new Keyword();
                keyword2.text = "cheap cruise";
                keyword2.matchType = KeywordMatchType.PHRASE;

                Keyword keyword3 = new Keyword();
                keyword3.text = "cruise";
                keyword3.matchType = KeywordMatchType.EXACT;

                Keyword[] keywords = new Keyword[] { keyword1, keyword2, keyword3 };

                // Create a keyword estimate request for each keyword.
                List<KeywordEstimateRequest> keywordEstimateRequests = new List<KeywordEstimateRequest>();

                foreach (Keyword keyword in keywords)
                {
                    KeywordEstimateRequest keywordEstimateRequest = new KeywordEstimateRequest();
                    keywordEstimateRequest.keyword = keyword;
                    keywordEstimateRequests.Add(keywordEstimateRequest);
                }

                // Create negative keywords.
                Keyword negativeKeyword1 = new Keyword();
                negativeKeyword1.text = "moon walk";
                negativeKeyword1.matchType = KeywordMatchType.BROAD;

                KeywordEstimateRequest negativeKeywordEstimateRequest = new KeywordEstimateRequest();
                negativeKeywordEstimateRequest.keyword = negativeKeyword1;
                negativeKeywordEstimateRequest.isNegative = true;
                keywordEstimateRequests.Add(negativeKeywordEstimateRequest);

                // Create ad group estimate requests.
                AdGroupEstimateRequest adGroupEstimateRequest = new AdGroupEstimateRequest();
                adGroupEstimateRequest.keywordEstimateRequests = keywordEstimateRequests.ToArray();
                adGroupEstimateRequest.maxCpc = new Money();
                adGroupEstimateRequest.maxCpc.microAmount = 1000000;

                // Create campaign estimate requests.
                CampaignEstimateRequest campaignEstimateRequest = new CampaignEstimateRequest();
                campaignEstimateRequest.adGroupEstimateRequests = new AdGroupEstimateRequest[] {
            adGroupEstimateRequest};

                // Optional: Set additional criteria for filtering estimates.
                // for a detailed list of country codes.
                Location countryCriterion = new Location();
                countryCriterion.id = 2840; //US

                // for a detailed list of language codes.
                Language languageCriterion = new Language();
                languageCriterion.id = 1000; //en

                campaignEstimateRequest.criteria = new Criterion[] { countryCriterion, languageCriterion };

                try
                {
                    // Create the selector.
                    TrafficEstimatorSelector selector = new TrafficEstimatorSelector()
                    {
                        campaignEstimateRequests = new CampaignEstimateRequest[] { campaignEstimateRequest },

                        // Optional: Request a list of campaign level estimates segmented by platform.
                        platformEstimateRequested = true
                    };

                    // Get traffic estimates.
                    TrafficEstimatorResult result = trafficEstimatorService.get(selector);

                    // Display traffic estimates.
                    if (result != null && result.campaignEstimates != null &&
                        result.campaignEstimates.Length > 0)
                    {
                        CampaignEstimate campaignEstimate = result.campaignEstimates[0];

                        // Display the campaign level estimates segmented by platform.
                        if (campaignEstimate.platformEstimates != null)
                        {
                            foreach (PlatformCampaignEstimate platformEstimate in
                                campaignEstimate.platformEstimates)
                            {
                                string platformMessage = string.Format("Results for the platform with ID: " +
                                    "{0} and name : {1}.", platformEstimate.platform.id,
                                    platformEstimate.platform.platformName);

                                DisplayMeanEstimates(platformMessage, platformEstimate.minEstimate,
                                    platformEstimate.maxEstimate);
                            }
                        }

                        // Display the keyword estimates.
                        if (campaignEstimate.adGroupEstimates != null &&
                            campaignEstimate.adGroupEstimates.Length > 0)
                        {
                            AdGroupEstimate adGroupEstimate = campaignEstimate.adGroupEstimates[0];

                            if (adGroupEstimate.keywordEstimates != null)
                            {
                                for (int i = 0; i < adGroupEstimate.keywordEstimates.Length; i++)
                                {
                                    Keyword keyword = keywordEstimateRequests[i].keyword;
                                    KeywordEstimate keywordEstimate = adGroupEstimate.keywordEstimates[i];

                                    if (keywordEstimateRequests[i].isNegative)
                                    {
                                        continue;
                                    }
                                    string kwdMessage = string.Format("Results for the keyword with text = '{0}' " +
                                        "and match type = '{1}':", keyword.text, keyword.matchType);
                                    DisplayMeanEstimates(kwdMessage, keywordEstimate.min, keywordEstimate.max);
                                }
                            }
                        }
                    }
                    else {
                        Console.WriteLine("No traffic estimates were returned.");
                    }
                    trafficEstimatorService.Close();
                }
                catch (Exception e)
                {
                    throw new System.ApplicationException("Failed to retrieve traffic estimates.", e);
                }
            }

Sreelakshmi Sasidharan (AdWords API Team)

unread,
Sep 11, 2018, 2:30:20 PM9/11/18
to AdWords API and Google Ads API Forum
Hi Qaiser, 

You can also use the TrafficEstimatorService to obtain information similar to the Plan your budget and get forecasts feature of the AdWords Keyword Planner. As you can see in the UI, not all criterion is supported in this service. Ad Schedule is not a supported criteria. You can only set Location and Language as criterion. Though date range is supported in UI, it is not possible to set this in the API. You could check this table which shows the mapping between the UI and the API service for more clarity. Please let me know if you have any additional questions. 

Thanks,
Sreelakshmi, AdWords API Team

Qaiser Javed

unread,
Sep 12, 2018, 2:08:20 AM9/12/18
to AdWords API and Google Ads API Forum
Hi Sreelakshmi,

Thank you, Your answer resolve my query.

Qaiser Javed

unread,
Sep 18, 2018, 9:26:05 AM9/18/18
to AdWords API and Google Ads API Forum
Hi Sreelakshmi,

I have a question please. Can I get maxcpc and suggested daily budget using TrafficEstimatorService? As it shown in UI.

Thanks & Regards,
Qaiser Javed

On Tuesday, September 11, 2018 at 11:30:20 PM UTC+5, Sreelakshmi Sasidharan (AdWords API Team) wrote:

Sreelakshmi Sasidharan (AdWords API Team)

unread,
Sep 18, 2018, 4:29:05 PM9/18/18
to AdWords API and Google Ads API Forum
Hi Qaiser,

The KeywordEstimate object within the AdGroupEstimate will contain the lower bound (min) and upper bound (max) of the traffic estimation (StatsEstimate) for each keyword. Please check here for more details. As shown in the code sample, you will be able to get the estimated average cpc and estimated average cost by taking the mean of the min and max values. Please note that returned values are estimates, and are not a guarantee that actual performance will be within these bounds. Also, these may not be the same value as in the UI.

Qaiser Javed

unread,
Sep 19, 2018, 7:14:36 AM9/19/18
to AdWords API and Google Ads API Forum
Hi Sreelakshmi,

Thanks for you reply. I have check these objects and got mean values.

I got following values (Mean) from TrafficEstimatorService.
 
Estimated daily clicks: 3.261019
Estimated daily impressions: 101.0461
Click Through Rate: 0.0322725810110569
Estimated average CPC: 2
Estimated ad position: 1.78
Estimated daily cost: 9

I have questions:

1. Why these values not matching with AdWords UI numbers?
2. Can I get "Suggested Daily Budget" from this service?
3. If I can't get suggested daily budget then how I can calculate daily budget with above numbers?
4. If I consider cost = daily budget it would be sensible?
5. Because date is not supported in this service, then if I consider 15 days then for 15 days can I calculate budget like 15 days budget = 15 * Cost it would be sensible?


Thanks & Regards,
Qaiser Javed


Sreelakshmi Sasidharan (AdWords API Team)

unread,
Sep 19, 2018, 1:27:17 PM9/19/18
to AdWords API and Google Ads API Forum
Hi Qaiser, 

I tested the same setting as in the API code sample with the new and old version of the keyword planner (you will be able to navigate to the old version by clicking the link at the bottom of the home page of new Keyword Planner UI). In my testing, the API results were comparable with both the versions though much closer to the old version of the UI. Please see the results from both new and old UI for comparison along with the results from the API.  For instance, the exact match type keyword 'cruise' and phrase match type keyword 'cheap cruise' with all the other settings as in the API code sample (Location: US, language: English, Bid : $1, negative keyword : 'hiking tour', PlatformEstimateRequested= false) were used for comparison. The values in the old UI is comparable with the value returned by the API. That said, you can also use the new UI view to compare. You will need to make sure that the settings are same as in the API input and the date range is for one day or divide the total metrics by the days selected. 

Results from API:

Results for the keyword with text 'cheap cruise' and match type 'PHRASE':
Estimated average CPC: 654064.00
Estimated ad position: 4.42
Estimated daily clicks: 136.92
Estimated daily cost: 89553928.00

Results for the keyword with text 'cruise' and match type 'EXACT':
Estimated average CPC: 725838.00
Estimated ad position: 4.09
Estimated daily clicks: 489.45
Estimated daily cost: 355263776.00

Please find my responses to your questions inline: 
  1. Why these values not matching with AdWords UI numbers?
  1. As described above. Please make sure that the API input matches the settings in the UI including the negative keyword, bid etc.
  1. Can I get "Suggested Daily Budget" from this service?
  1. The "Estimated daily cost" in the API code sample is the suggested daily cost. In new UI, please make sure to divide the total cost by number of days in the selected date range. In the old UI the stats are per day. 
  1. If I can't get suggested daily budget then how I can calculate daily budget with above numbers?
  1. Same as the answer for #2 
  1. If I consider cost = daily budget it would be sensible?
  1. As described above.
  1. Because date is not supported in this service, then if I consider 15 days then for 15 days can I calculate budget like 15 days budget = 15 * Cost it would be sensible?
  1. Yes, you will need to multiply the API results with number of days to get the total cost. 
TrafficEstimator-NewUI.png
TrafficEstimates.png
Reply all
Reply to author
Forward
0 new messages