Google AdWords API – Part 3

11 Antworten

  1. Michel FLEITH sagt:

    Thank you for this example, unfortunately i’ve tested and adwords return me :

    an error has occurred: [SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’AverageCpc‘, SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’AveragePosition‘, SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’Clicks‘, SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’Conversions‘, SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’Cost‘, SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’Ctr‘, SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:’Impressions‘]

    I don’t know why, and you ?

    • Hello!
      INVALID_FIELD_NAME occurs if the given field does not exist in the current used Adwords API version. You can find a list of all possible fields for each service under this link: Google Adwords API. It depends on which API version you are using. In the current version, AverageCpc is not a valid field for AdGroupAdService, so please fill in correct field names at $selector->fields = array()! Hope this helps 😉

  2. José sagt:

    Hi, what is $adGroupId? And, where I get it?

    • This article shows you for example how the get TextAds with „function GetTextAds“. On of its params is adGroupId. You can get an adGroupId the same way as TextAds. For this you need campaignId which you can also get the same way. In Part 2 of my article series I describe this steps in detail!

  3. Kurian sagt:

    I was trying to use this code. But looks likes the api has changed. Can you please tell me how can i get the data available in „GetKeywords“. I am looking for ‚Clicks‘, ‚Conversions‘, ‚Cost‘, ‚Ctr‘, ‚Impressions‘ for the keywords

    Will you be able to help

    • The API is highly dynamic and Google changes things every 6 months or so…my last status was, that you have to use reports. This is the last working source I have

      function DownloadKeywordReport(AdWordsUser $user, $filePath, $adwords_version, $keyword_id, $days, $adGroupId) {
        // Load the service, so that the required classes are available.
        $user->LoadService('ReportDefinitionService', $adwords_version);
      
        // Create selector.
        $selector = new Selector();
        $selector->fields = array('KeywordText', 'Id', 'TotalConvValue', 'AverageCpc', 'AveragePosition', 'Clicks', 'Conversions', 'Cost', 'Ctr', 'Impressions', 'QualityScore', 'Status');
      
        // Filter out deleted criteria.
        //$selector->predicates[] = new Predicate('Status', 'NOT_IN', array('DELETED'));
        $selector->predicates[] = new Predicate('AdGroupId', 'IN', array($adGroupId));
        $selector->predicates[] = new Predicate('Id', 'IN', $keyword_id);
        
        $dateRange = new DateRange();
        $str1 = '-1 days';
        $str2 = '-1 days';
        if($days > 0)
        {
          $str1 = '-'.$days.' days';
          $str2 = '-'.$days.' days';
        }
        $dateRange->min = date('Ymd', strtotime($str1));
        $dateRange->max = date('Ymd', strtotime($str2));
        $selector->dateRange = $dateRange;
      
        // Create report definition.
        $reportDefinition = new ReportDefinition();
        $reportDefinition->selector = $selector;
        $reportDefinition->reportName = 'Criteria performance report #' . uniqid();
        $reportDefinition->dateRangeType = 'CUSTOM_DATE';
        $reportDefinition->reportType = 'KEYWORDS_PERFORMANCE_REPORT';
        $reportDefinition->downloadFormat = 'XML';
      
        // Exclude criteria that haven't recieved any impressions over the date range.
        $reportDefinition->includeZeroImpressions = FALSE;
      
        // Set additional options.
        $options = array('version' => $adwords_version, 'returnMoneyInMicros' => FALSE);
      
        ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);
      }

      hope this helps!

  4. Vikrant sagt:

    i have a client library in asp.net of v201502 and i want to fecth all the clicks,item-id,impressions,cost,conversion of all the campaigns within a given date range from the google adword api.please help me its too urgent.if anyone has any example its better.thanks in advance

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert