TrafficEstimatorService Not giving equal monthly volume compared with Keyword Planner Tool volume

579 views
Skip to first unread message

Manjula Naidu

unread,
Apr 2, 2014, 5:35:28 AM4/2/14
to adwor...@googlegroups.com
Hi all,

       <?xml version="1.0" encoding="UTF-8"?>

<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="https://adwords.google.com/api/adwords/o/v201309" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:cm="https://adwords.google.com/api/adwords/cm/v201309">

    <env:Header>

        <wsdl:RequestHeader xmlns="https://adwords.google.com/api/adwords/cm/v201309">

            <userAgent>${userAgent}</userAgent>

            <developerToken>${developerToken}</developerToken>

            <clientCustomerId>${customerID}</clientCustomerId>

            <authToken>${authToken}</authToken>

        </wsdl:RequestHeader>

    </env:Header>

    <env:Body>

        <get xmlns="https://adwords.google.com/api/adwords/o/v201309">

            <selector>

                <campaignEstimateRequests>

                    <adGroupEstimateRequests>

                       <keywordEstimateRequests>

    <wsdl:keyword xmlns="https://adwords.google.com/api/adwords/cm/v201309">

        <text>${keyword}</text>

        <matchType>PHRASE</matchType>

    </wsdl:keyword>

</keywordEstimateRequests>


                        <wsdl:maxCpc xmlns="https://adwords.google.com/api/adwords/cm/v201309">

                            <microAmount>${maxCpc}</microAmount>

                        </wsdl:maxCpc>

                        </adGroupEstimateRequests>

                   <searchParameters xsi:type="CountryTargetSearchParameter">

    <wsdl:countryTargets xmlns="https://adwords.google.com/api/adwords/cm/v201309"> 

         <cm:countryCode>${countryCode}</cm:countryCode> 

    </wsdl:countryTargets>

</searchParameters>

                    <networkSetting>

                        <targetGoogleSearch xmlns="https://adwords.google.com/api/adwords/cm/v201309">true</targetGoogleSearch>

                        <targetSearchNetwork xmlns="https://adwords.google.com/api/adwords/cm/v201309">true</targetSearchNetwork>

                        <targetContentNetwork xmlns="https://adwords.google.com/api/adwords/cm/v201309">false</targetContentNetwork>

                        <targetPartnerSearchNetwork xmlns="https://adwords.google.com/api/adwords/cm/v201309">false</targetPartnerSearchNetwork>

                    </networkSetting>

                </campaignEstimateRequests>

            </selector>

        </get>

    </env:Body>

</env:Envelope>

 This soap request i used to get the TrafficEstimatorService,I am getting wrong values of particular keyword.I compared with keyword planner tool monthly data with my application TrafficEstimatorService response ,but not even one month volume is equal to keyword planner tool data,please could you people  help in this.


     Thanks in advance.



Thanks and Regards

R.manjula


Message has been deleted

Josh Radcliff (AdWords API Team)

unread,
Apr 2, 2014, 3:02:06 PM4/2/14
to adwor...@googlegroups.com
Hi,

Are you sure your request is for the estimator service?  The request below looks like a TargetingIdeaService request, not a TrafficEstimatorService request.  In addition, I see you are using the CountryTargetSearchParameter, but that was replaced by LocationSearchParameter.

If the two points above don't answer your question, could you indicate which "What would you like to do?" option you are using in the Keyword Planner?

Thanks,
Josh, AdWords API Team

Josh Radcliff (AdWords API Team)

unread,
Apr 3, 2014, 8:15:53 PM4/3/14
to adwor...@googlegroups.com
Hi,

If you are trying to match the Get search volume for a list of keywords or group them into ad groups option, then you should match (I confirmed myself) if you include the following parameters:
  1. A RelatedToQuerySearchParameter for the keyword(s)
  2. A NetworkSearchParameter with each value set to match the UI (it appears that by default each value is set to true for the API).  For example, if you use the default settings you would pass:
    • targetGoogleSearch = true
    • targetSearchNetwork = false
    • targetContentNetwork = false
    • targetPartnerSearchNetwork = false
  3. IdeaType KEYWORD
  4. Request type STATS
  5. Requested attribute types:
    • KEYWORD_TEXT
    • SEARCH_VOLUME
    • TARGETED_MONTHLY_SEARCHES
Below is the body from an example request for the keyword flower.

<soapenv:Body>
        <selector>
            <searchParameters xmlns:ns7="https://adwords.google.com/api/adwords/o/v201402" xsi:type="ns7:RelatedToQuerySearchParameter">
                <ns7:queries>flower</ns7:queries>
            </searchParameters>
            <searchParameters xmlns:ns8="https://adwords.google.com/api/adwords/o/v201402" xsi:type="ns8:NetworkSearchParameter">
                <ns8:networkSetting>
                    <ns9:targetGoogleSearch xmlns:ns9="https://adwords.google.com/api/adwords/cm/v201402">true</ns9:targetGoogleSearch>
                    <ns10:targetSearchNetwork xmlns:ns10="https://adwords.google.com/api/adwords/cm/v201402">false</ns10:targetSearchNetwork>
                    <ns11:targetContentNetwork xmlns:ns11="https://adwords.google.com/api/adwords/cm/v201402">false</ns11:targetContentNetwork>
                    <ns12:targetPartnerSearchNetwork xmlns:ns12="https://adwords.google.com/api/adwords/cm/v201402">false</ns12:targetPartnerSearchNetwork>
                </ns8:networkSetting>
            </searchParameters>
            <ideaType>KEYWORD</ideaType>
            <requestType>STATS</requestType>
            <requestedAttributeTypes>KEYWORD_TEXT</requestedAttributeTypes>
            <requestedAttributeTypes>SEARCH_VOLUME</requestedAttributeTypes>
            <requestedAttributeTypes>TARGETED_MONTHLY_SEARCHES</requestedAttributeTypes>
            <paging>
                <ns13:startIndex xmlns:ns13="https://adwords.google.com/api/adwords/cm/v201402">0</ns13:startIndex>
                <ns14:numberResults xmlns:ns14="https://adwords.google.com/api/adwords/cm/v201402">10</ns14:numberResults>
            </paging>
        </selector>
    </get>
</soapenv:Body>

Cheers,
Josh, AdWords API Team

Manjula Naidu

unread,
Apr 4, 2014, 5:31:33 AM4/4/14
to Josh Radcliff, adwor...@googlegroups.com
Hi,

     Thanks for your response, I think this request is for TargetIdea service ,Because this request containing search parameter.I already implemented TargetIdeaService ,Now  I have to implement for TrafficEstimation service for getting particular keyword monthly search volume.
         
In my code this is my soap request



            This is url :

   <?xml version="1.0" encoding="UTF-8"?>

<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:wsdl="https://adwords.google.com/api/adwords/o/v201309"xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cm="https://adwords.google.com/api/adwords/cm/v201309">

    <env:Header>

        <wsdl:RequestHeader xmlns="https://adwords.google.com/api/adwords/cm/v201309">

            <userAgent>${userAgent}</userAgent>

            <developerToken>${developerToken}</developerToken>

            <clientCustomerId>${customerID}</clientCustomerId>

            <authToken>${authToken}</authToken>

        </wsdl:RequestHeader>

    </env:Header>

    <env:Body>

        <get xmlns="https://adwords.google.com/api/adwords/o/v201309">

            <selector>

                <campaignEstimateRequests>

                    <adGroupEstimateRequests>

                       <keywordEstimateRequests>

    <wsdl:keyword xmlns="https://adwords.google.com/api/adwords/cm/v201309">

        <text>${keyword}</text>

        <matchType>EXACT</matchType>

    </wsdl:keyword>

</keywordEstimateRequests>


                        <wsdl:maxCpc xmlns="https://adwords.google.com/api/adwords/cm/v201309">

                            <microAmount>${maxCpc}</microAmount>

                        </wsdl:maxCpc>

                        </adGroupEstimateRequests>


        <criteria xsi:type="cm:Location">

    <cm:id>${criteriaID}</cm:id>

</criteria>


                  

     <networkSetting>

                        <targetGoogleSearchxmlns="https://adwords.google.com/api/adwords/cm/v201309">true</targetGoogleSearch>

                        <targetSearchNetworkxmlns="https://adwords.google.com/api/adwords/cm/v201309">true</targetSearchNetwork>

                        <targetContentNetworkxmlns="https://adwords.google.com/api/adwords/cm/v201309">false</targetContentNetwork>

                        <targetPartnerSearchNetworkxmlns="https://adwords.google.com/api/adwords/cm/v201309">false</targetPartnerSearchNetwork>

                    </networkSetting>

                     

                </campaignEstimateRequests>

            </selector>

        </get>

    </env:Body>

</env:Envelope>

 


Please i need Urgent response,I spent almost one week on this i am unable to give exact volumes ,and coming to Average volume



In keyword planner :
For flower keyword monthly searches are

550000    550000   550000    550000    550000   550000    550000  550000 
550000    550000   673000    673000


IN keyword planner,keyword idea AVG Monthly search:550,000


IF I am doing manual average of above month volumes I am getting this value:570500


How you people doing average of monthly search how i can do.


    Thanks in advance.




Thanks & Regards 


R.manjula









--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Josh Radcliff (AdWords API Team)

unread,
Apr 4, 2014, 1:16:05 PM4/4/14
to adwor...@googlegroups.com, Josh Radcliff
Hi,

The TrafficEstimatorService is for estimating future statistics based on recent performance.  The TargetingIdeaService is for using past statistics to get ideas and suggestions for your account.  For the use case you described--getting particular keyword monthly search volume--you should use the TargetingIdeaService, not TrafficEstimatorService.  My previous response illustrated how to construct a request that matches the monthly search volume you'll see in the Keyword Planner under the Get search volume for a list of keywords or group them into ad groups option.

Regarding the average that you see in Keyword Planner, the SEARCH_VOLUME stat I mentioned below will provide that information, so I don't quite understand why you want to calculate the value on your own.

If I have not answered your questions could you provide the exact steps in Keyword Planner that you are trying to replicate through the API?

Thanks,
Josh, AdWords API Team
...

suga priya

unread,
Aug 11, 2014, 10:38:26 AM8/11/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi Josh,

I am trying to get traffic estimate for keyword.i am using TrafficEstimatorService  for that.But values are not matching with keyword planner tool.Please find the codes and attachment.

<?php
/**
 * This example gets traffic estimates for new keywords.
 *
 * Tags: TrafficEstimatorService.get
 * Restriction: adwords-only
 *
 * Copyright 2014, Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package    GoogleApiAdsAdWords
 * @subpackage v201406
 * @category   WebServices
 * @copyright  2014, Google Inc. All Rights Reserved.
 * @license    http://www.apache.org/licenses/LICENSE-2.0 Apache License,
 *             Version 2.0
 * @author     Eric Koleda
 */

// Include the initialization file
require_once dirname(dirname(__FILE__)) . '/init.php';

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 */
function EstimateKeywordTrafficExample(AdWordsUser $user) {

$trafficEstimatorService =
$user->GetService('TrafficEstimatorService', ADWORDS_VERSION);


$keywords = array();
$keywords[] = new Keyword('leasing software', 'BROAD');

  $negativeKeywords = array();

  // Create a keyword estimate request for each keyword.
  $keywordEstimateRequests = array();
  foreach ($keywords as $keyword) {
    $keywordEstimateRequest = new KeywordEstimateRequest();
    $keywordEstimateRequest->keyword = $keyword;
    $keywordEstimateRequests[] = $keywordEstimateRequest;
  }

  // Create a keyword estimate request for each negative keyword.
  foreach ($negativeKeywords as $negativeKeyword) {
    $keywordEstimateRequest = new KeywordEstimateRequest();
    $keywordEstimateRequest->keyword = $negativeKeyword;
    $keywordEstimateRequest->isNegative = TRUE;
    $keywordEstimateRequests[] = $keywordEstimateRequest;
  }

  // Create ad group estimate requests.
  $adGroupEstimateRequest = new AdGroupEstimateRequest();
  $adGroupEstimateRequest->keywordEstimateRequests = $keywordEstimateRequests;
  $adGroupEstimateRequest->maxCpc = new Money(1000000);

  // Create campaign estimate requests.
  $campaignEstimateRequest = new CampaignEstimateRequest();
  $campaignEstimateRequest->adGroupEstimateRequests[] = $adGroupEstimateRequest;

  // Set targeting criteria. Only locations and languages are supported.
  $unitedStates = new Location();
  $unitedStates->id = 2840;
  $campaignEstimateRequest->criteria[] = $unitedStates;

  $english = new Language();
  $english->id = 1000;
  $campaignEstimateRequest->criteria[] = $english;

  
  // Create selector.
  $selector = new TrafficEstimatorSelector();
  $selector->campaignEstimateRequests[] = $campaignEstimateRequest;

  // Make the get request.
  $result = $trafficEstimatorService->get($selector);

  // Display results.
  $keywordEstimates =
      $result->campaignEstimates[0]->adGroupEstimates[0]->keywordEstimates;
  for ($i = 0; $i < sizeof($keywordEstimates); $i++) {
    $keywordEstimateRequest = $keywordEstimateRequests[$i];
    // Skip negative keywords, since they don't return estimates.
    if (!$keywordEstimateRequest->isNegative) {
      $keyword = $keywordEstimateRequest->keyword;
      $keywordEstimate = $keywordEstimates[$i];
      // Find the mean of the min and max values.
      $meanAverageCpc = ($keywordEstimate->min->averageCpc->microAmount
          + $keywordEstimate->max->averageCpc->microAmount) / 2;
      $meanAveragePosition = ($keywordEstimate->min->averagePosition
          + $keywordEstimate->max->averagePosition) / 2;
      $meanClicks = ($keywordEstimate->min->clicksPerDay
          + $keywordEstimate->max->clicksPerDay) / 2;
      $meanTotalCost = ($keywordEstimate->min->totalCost->microAmount
          + $keywordEstimate->max->totalCost->microAmount) / 2;

      printf("Results for the keyword with text '%s' and match type '%s':\n",
          $keyword->text, $keyword->matchType);
      printf("  Estimated average CPC in micros: %.0f\n", $meanAverageCpc);
      printf("  Estimated ad position: %.2f \n", $meanAveragePosition);
      printf("  Estimated daily clicks: %d\n", $meanClicks);
      printf("  Estimated daily cost in micros: %.0f\n\n", $meanTotalCost);
    }
  }
}

// Don't run the example if the file is being included.
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) {
  //return;
}

try {
  // Get AdWordsUser from credentials in "../auth.ini"
  // relative to the AdWordsUser.php file's directory.
  $user = new AdWordsUser();

  // Log every SOAP XML request and response.
  $user->LogAll();

  // Run the example.
  EstimateKeywordTrafficExample($user);
} catch (Exception $e) {
  printf("An error has occurred: %s\n", $e->getMessage());
}



...

suga priya

unread,
Aug 11, 2014, 10:39:36 AM8/11/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Results for the keyword with text 'leasing software' and match type 'BROAD': Estimated average CPC in micros: 588280 Estimated ad position: 3.35 Estimated daily clicks: 0 Estimated daily cost in micros: 204688
<font face="c
...

Josh Radcliff (AdWords API Team)

unread,
Aug 11, 2014, 3:31:20 PM8/11/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi,

I'm not quite sure what the purpose/question was of your most recent post, but I would recommend reading through our new Estimating Traffic guide to see if that answers your question.

Thanks,
Josh, AdWords API Team
                    <ns11:targetContentNetwork xmlns:ns11="<a href="https://adwords.google.com/api/adwords/cm/v201402" target="_blank" onmousedown="this.href='https://adwords.google.com/api/adwords/c
...

suga priya

unread,
Aug 11, 2014, 4:34:16 PM8/11/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi Josh,

 Avg position value is not matching with keyword planner tool. I set language,location and network  parameters as well.For "leasing software"  through api i am getting 3.35 but in keyword planner tool i am getting 3.31.


Please help me to fix this issue


Thanks,
Sugappriya

For eg  
                    <ns10:targetSearchNetwork xmlns:ns10="<a href="https://adwords.google.com/api/adwords/cm/v201402" target="_blank" onmousedown="this.href='https://adwords.google.com/api/adword
...

Josh Radcliff (AdWords API Team)

unread,
Aug 11, 2014, 6:02:33 PM8/11/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi,

Are you submitting the API request and the UI request at essentially the same time, and using the same account and credentials?

Thanks,
Josh, AdWords API Team
        &nb
...

suga priya

unread,
Aug 12, 2014, 5:08:31 AM8/12/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Yes.I am getting other values like Clicks,Impression and Cost as same as UI, only Avg Position has variation in points.Also through API Is it possible to get weekly estimates?

If so how to set Date Range and date range is not supported by API. Any solution?

Thanks,
Sugappriya
        &nbs
...

Josh Radcliff (AdWords API Team)

unread,
Aug 13, 2014, 1:41:33 AM8/13/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi Sugappriya,

The API does not support weekly estimates or date ranges. The difference between the UI and the API is most likely due to the following point mentioned in the TrafficEstimatorService documentation:

Note that the API returns intervals whereas the Traffic Estimator UI displays averages.

Thanks,
Josh, AdWords API Team
...

suga priya

unread,
Aug 14, 2014, 11:14:06 AM8/14/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi Josh,

I am accepting your point.Its returning min and max value,we can find avg of those two values.By making avg I am getting exact value for clicks,impr,cost & CTR as compared with UI but why not Avg position


Thanks,
Sugappriya
...

suga priya

unread,
Aug 18, 2014, 5:52:23 AM8/18/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi Josh.

Can you help me to fix this issue?

Thanks,
Sugappriya
...

Josh Radcliff (AdWords API Team)

unread,
Aug 19, 2014, 7:18:27 PM8/19/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi Sugappriya,

The Keyword Planner may be calculating the average differently for position. We can't guarantee that you'll be able to produce the exact same results in the API. Does a difference in the second decimal place of an average really have a significant impact on your application?

Thanks,
Josh, AdWords API Team
  1. A&n
...

suga priya

unread,
Aug 20, 2014, 5:32:04 PM8/20/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi Josh,

Difference in second decimal digit is impacting in setting budget.For eg avg position 1.99 will set one budget and for 2.00 will increase budget.Is there any solution to resolve this issue.


Thanks for your help



<br

...

Josh Radcliff (AdWords API Team)

unread,
Aug 21, 2014, 4:45:38 PM8/21/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi,

From tests I just ran, it appears that the Keyword Planner is not calculating its displayed Avg. Pos. strictly as an average of the min and max Ad position. For example, I have:

Keyword Planner
Ad position = 3.36 - 4.1
Avg. Pos. = 3.70

However, if I take the average of the min and max Ad position values, I get:
(3.36 + 4.1)/2 = 3.73

In other words, the Keyword Planner value for Avg. Pos. is clearly not just a simple average of the min and the max.

One possibility is that it is calculating the Avg. Pos. using a weighted average, e.g., by weighting on Impressions. That gets close to the value, but is not always an exact match. See the section on the right that shows one possible weighted average calculation.

Keyword PlannerAvgPositionImpressionsPerDay
Min4.112.6Min AvgPosition * ImpressionsPerDay51.66
Max3.3615.4Max AvgPosition * ImpressionsPerDay51.744
Avg (Calculated)3.7314Weighted Total103.404
UI Avg Pos.3.70Total Impressions28
Weighted Average (Weighted Total / Total Impressions)3.69

If you need to know exactly how the Keyword Planner UI performs its calculations, please use the Contact Us link in the AdWords Help Center. They may be able to provide you with more details.

Thanks,
Josh, AdWords API Team

<span style="color:rgb(34,34,34);f

...

suga priya

unread,
Aug 23, 2014, 5:04:36 AM8/23/14
to adwor...@googlegroups.com, adwordsapia...@google.com
Thanks for the help,I will try your solution.If we have any issues i will contact them.

                        <targetGoogleSearch<span style="color:rgb(15

...

suga priya

unread,
Feb 2, 2015, 10:30:02 AM2/2/15
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi,

TrafficEstimatorService min & max  impression per day is not matching with keyword planner UI but adgroup position are correct. Please help me to fix this issue

Thanks,
Sugappriya

Sugappriya Palanisamy

unread,
Feb 2, 2015, 11:44:48 AM2/2/15
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi,
We changed the client customer id recently..Before it was working fine

Josh Radcliff (AdWords API Team)

unread,
Feb 2, 2015, 2:09:29 PM2/2/15
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi Sugappriya,

Please make sure you are setting the NetworkSetting to the proper values as noted in the Traffic Estimator Guide.

Thanks,
Josh, AdWords API Team

Sugappriya Palanisamy

unread,
Feb 3, 2015, 7:06:39 AM2/3/15
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi Josh,

I used below code for Network settings (only for the Google). But the issue is still persistent
  $network = new networkSetting();
  $network->targetGoogleSearch = true;
  $network->targetSearchNetwork = false;
  $network->targetPartnerSearchNetwork  = false;
  $network->targetContentNetwork    =    false;

 Client customer Id is changed due to transfer from adwords account to mcc account and no ads are running now. Will it be the cause of issue? I remembered it was working fine before transfer.

Thanks.
Sugappriya

Sugappriya Palanisamy

unread,
Feb 3, 2015, 7:10:00 AM2/3/15
to adwor...@googlegroups.com, adwordsapia...@google.com
Please find full code

<?php
require_once dirname(dirname(__FILE__)) . '/init.php';
function getKeywordTraffic(AdWordsUser $user,$keyword,$locationId,$languageId,$budget) {
    $min_po =0;$max_po=0;
    $budget = $budget *1000000;

    $trafficEstimatorService =
    $user->GetService('TrafficEstimatorService', ADWORDS_VERSION);
    $keywords = array();
    $keywords[] = new Keyword($keyword, 'BROAD');
    $negativeKeywords = array();
    //$negativeKeywords[] = new Keyword('');

  // Create a keyword estimate request for each keyword.
    $keywordEstimateRequests = array();
      foreach ($keywords as $keyword) {
        $keywordEstimateRequest = new KeywordEstimateRequest();
        $keywordEstimateRequest->keyword = $keyword;
        $keywordEstimateRequests[] = $keywordEstimateRequest;
      }
  // Create a keyword estimate request for each negative keyword.
      foreach ($negativeKeywords as $negativeKeyword) {
        $keywordEstimateRequest = new KeywordEstimateRequest();
        $keywordEstimateRequest->keyword = $negativeKeyword;
        $keywordEstimateRequest->isNegative = TRUE;
        $keywordEstimateRequests[] = $keywordEstimateRequest;
      }

  // Create ad group estimate requests.
    $adGroupEstimateRequest = new AdGroupEstimateRequest();
    $adGroupEstimateRequest->keywordEstimateRequests = $keywordEstimateRequests;
    $adGroupEstimateRequest->maxCpc = new Money($budget);


  // Create campaign estimate requests.
    $campaignEstimateRequest = new CampaignEstimateRequest();
    $campaignEstimateRequest->adGroupEstimateRequests[] = $adGroupEstimateRequest;

    // Set targeting criteria. Only locations and languages are supported.
    $unitedStates = new Location();
    $unitedStates->id = $locationId;

    $campaignEstimateRequest->criteria[] = $unitedStates;

    $english = new Language();
    $english->id = $languageId;
    $campaignEstimateRequest->criteria[] = $english;

 
    $network = new networkSetting();
    $network->targetGoogleSearch = true;
    $network->targetSearchNetwork = false;
    $network->targetPartnerSearchNetwork  = false;
    $network->targetContentNetwork    =    false;
    $campaignEstimateRequests->networkSetting[] = $network;

 
    // Create selector.
    $selector = new TrafficEstimatorSelector();
    $selector->campaignEstimateRequests[] = $campaignEstimateRequest;

    // Make the get request.
    $result = $trafficEstimatorService->get($selector);

    // Display results.
  $keywordEstimates = $result->campaignEstimates[0]->adGroupEstimates[0]->keywordEstimates;
    for ($i = 0; $i < sizeof($keywordEstimates); $i++) {
        $keywordEstimateRequest = $keywordEstimateRequests[$i];
    // Skip negative keywords, since they don't return estimates.
    if (!$keywordEstimateRequest->isNegative) {
      $keyword = $keywordEstimateRequest->keyword;
      $keywordEstimate = $keywordEstimates[$i];
     

      // Find the mean of the min and max values.
      if(isset($keywordEstimate->min->averageCpc->microAmount) && isset($keywordEstimate->max->averageCpc->microAmount) ){

            $meanAverageCpc = ($keywordEstimate->min->averageCpc->microAmount
            + $keywordEstimate->max->averageCpc->microAmount) / 2;
            $meanAvgCPC = number_format(($meanAverageCpc/1000000),2);
        }
        else{
            $meanAvgCPC = '';
        }
        if(isset($keywordEstimate->min->averagePosition) && isset($keywordEstimate->max->averagePosition) ){
            $min_po = number_format($keywordEstimate->min->averagePosition,2);
            $max_po    = number_format($keywordEstimate->max->averagePosition,2);

            $meanAveragePosition = ($keywordEstimate->min->averagePosition
            + $keywordEstimate->max->averagePosition) / 2;
            $meanAveragePos = number_format($meanAveragePosition,2);
            $keywordEstimate->min->impressionsPerDay;
           
            $TotalImpr = ($keywordEstimate->min->impressionsPerDay
            + $keywordEstimate->max->impressionsPerDay);
            $min_poAvg = $keywordEstimate->min->averagePosition * $keywordEstimate->min->impressionsPerDay;
            $max_poAvg    = $keywordEstimate->max->averagePosition * $keywordEstimate->max->impressionsPerDay;
            $Weighted_Total = $min_poAvg +     $max_poAvg;
            if($TotalImpr!=0){
            $Weighted_Average = number_format($Weighted_Total/$TotalImpr,2);
            }
            else{
                $Weighted_Average = $meanAveragePos;
            }
        }
        else{
            $meanAveragePos = "";
            $Weighted_Average ="";
        }
        $meanClicks =($keywordEstimate->min->clicksPerDay

        + $keywordEstimate->max->clicksPerDay) /2;
        $meanTotalCost   = ($keywordEstimate->min->totalCost->microAmount
        + $keywordEstimate->max->totalCost->microAmount) / 2;
       
        $meanImpr = ($keywordEstimate->min->impressionsPerDay
        + $keywordEstimate->max->impressionsPerDay) / 2;
       
        if(isset($keywordEstimate->min->clickThroughRate) && isset($keywordEstimate->max->clickThroughRate) ){
        $meanCTR = ($keywordEstimate->min->clickThroughRate
        + $keywordEstimate->max->clickThroughRate) / 2;
        $meanCTR = number_format($meanCTR *100,1);
        }
        else{
            $meanCTR = '';
        }
        $meanClicks     = number_format($meanClicks,2);
        $meanTotalCost = number_format(($meanTotalCost/1000000),2);
        $meanImp = number_format($meanImpr,2);
    }
  }
  return array($meanAvgCPC,$Weighted_Average,$meanClicks,$meanTotalCost,$meanImp,$meanCTR,$min_po,$max_po);
}
function RequestKeywordTraffic($keywordName,$locationId,$languageId,$budget,$clientId){
    $clientId = trim($clientId);
    $user = new AdWordsUser();
    $user->SetClientCustomerId($clientId);
    $user->LogAll();
    $result = getKeywordTraffic($user,$keywordName,$locationId,$languageId,$budget);
    return array($result[0],$result[1],$result[2],$result[3],$result[4],$result[5],$result[6],$result[7]);
...

suga priya

unread,
Feb 13, 2015, 11:42:19 AM2/13/15
to adwor...@googlegroups.com, adwordsapia...@google.com
Hi Josh,

Any update on this? Please help me to resolve this issue.
...
Reply all
Reply to author
Forward
0 new messages