Hi MM, I tried your suggestions and I changed my $reportDefinition- >dateRangeType = 'LAST_7_DAYS'; I can see data for that date range (last 7 days) in UI. Do you know why I still could not get any data?
Thanks, Herbert On Apr 27, 7:49 am, mm <[email protected]> wrote: > Herbert - > Do you see results for that date range via the UI? I had the same > issue, then I found somewhere that search query results take longer to > be available than the others. For my purposes, I simply created a > report definition requesting data for the past week using > ReportDefinitionDateRangeType.LAST_7_DAYS so that I could re-use the > definition. Once I switched to that, I was consistently seeing results > in the report. > > HTH - > mm > > On Apr 27, 1:50 am, herbertbintoroe <[email protected]> wrote: > > > Hi All, > > > I am able to download keyword performance report by using the example > > in version 201101. > > > However, when I am trying to download search_query_performance_report > > (by changing the selector and report type from the keyword > > perfrormance report while creating the report definition ), I got a > > report with an empty data. > > > Is it because the data is not automatically added? Because I use the > > same ad group id for keyword performance report and it gives me some > > data. > > > Below is the result that I get. > > > <?xml version='1.0' encoding='UTF-8' standalone='yes'?><report><report- > > name name='Search Query performance report #1303886318'/><date-range > > date='Apr 23, 2011-Apr 25, 2011'/><table><columns><column > > name='adGroupID' display='Ad group ID'/><column name='campaignID' > > display='Campaign ID'/><column name='campaign' display='Campaign'/><column > > name='campaignState' display='Campaign state'/><column > > > name='keywordID' display='Keyword ID'/><column name='searchTerm' > > display='Search term'/><column name='totalConvValue' display='Total > > conv. value'/><column name='matchType' display='Match type'/><column > > name='impressions' display='Impressions'/><column name='clicks' > > display='Clicks'/><column name='cost' display='Cost'/></columns></ > > table></report> > > > And below is my code. Thanks in advance > > > error_reporting(E_STRICT | E_ALL); > > > $path = dirname(__FILE__) . '/../../src'; > > set_include_path(get_include_path() . PATH_SEPARATOR . $path); > > > require_once 'vendors/google_adwords/src/Google/Api/Ads/AdWords/Lib/ > > AdWordsUser.php'; > > require_once 'vendors/google_adwords/src/Google/Api/Ads/AdWords/Util/ > > ReportUtils.php'; > > > /** > > * > > * First we want to request for a report > > */ > > function addKeywordsPerformance($user){ > > try { > > // Get AdWordsUser from credentials in "../auth.ini" > > // relative to the AdWordsUser.php file's directory. > > $devtoken = $user->GetDeveloperToken(); > > > // Log SOAP XML request and response. > > $user->LogDefaults(); > > > // Get the GetReportDefinitionService. > > $reportDefinitionService = $user- > > > >GetReportDefinitionService('v201101'); > > > $startDate = date("Ymd", strtotime("-3 days")); > > $endDate = date("Ymd", strtotime("-1 days")); > > > // Create selector to indicate which fields we want to get > > $selector = new Selector(); > > $selector->fields = array('AdGroupId', 'CampaignId', > > 'CampaignName', > > 'CampaignStatus', 'KeywordId', 'Query', 'TotalConvValue', > > 'MatchType', 'Impressions', 'Clicks', 'Cost'); > > $selector->dateRange = new DateRange($startDate, $endDate); > > > // Create predicates. > > $adGroupId = 1814788471; > > $adGroupPredicate = new Predicate(); > > $adGroupPredicate->field = 'AdGroupId'; > > $adGroupPredicate->operator = 'EQUALS'; > > $adGroupPredicate->values = array($adGroupId); > > $selector->predicates = array($adGroupPredicate); > > > // Create report definition. > > $reportDefinition = new ReportDefinition(); > > $reportDefinition->reportName = 'Search Query performance > > report #' . time(); > > $reportDefinition->dateRangeType = 'CUSTOM_DATE'; > > $reportDefinition->reportType = > > 'SEARCH_QUERY_PERFORMANCE_REPORT'; > > $reportDefinition->downloadFormat = 'XML'; > > $reportDefinition->selector = $selector; > > > // Create operations. > > $operation = new ReportDefinitionOperation(); > > $operation->operand = $reportDefinition; > > $operation->operator = 'ADD'; > > > $operations = array($operation); > > > // Add report definition. > > $result = $reportDefinitionService->mutate($operations); > > > // Display report definitions. > > if ($result != null) { > > var_dump($result); > > print_r($result, true); > > foreach ($result as $reportDefinition) { > > printf("Report definition with name '%s' and id '%s' > > was added.\n", > > $reportDefinition->reportName, $reportDefinition->id); > > return $reportDefinition->id; > > } > > } else { > > print "No report definitions were added.\n"; > > } > > } catch (Exception $e) { > > print $e->getMessage(); > > exit(); > > } > > > } > > > try { > > // Get AdWordsUser from credentials in "../auth.ini" > > // relative to the AdWordsUser.php file's directory. > > $user = new AdWordsUser(); > > // Log SOAP XML request and response. > > $user->LogDefaults(); > > $reportDefinitionId = addKeywordsPerformance($user); > > print("Report definiton id = $reportDefinitionId"); > > $fileName = 'google_adword_search_performance.xml'; > > > $path = dirname(__FILE__) . '/' . $fileName; > > > // Download report. > > ReportUtils::DownloadReport($reportDefinitionId, $path, $user); > > > printf("Report with definition id '%s' was downloaded to '%s'.\n", > > $reportDefinitionId, $fileName);} catch (Exception $e) { > > > print $e->getMessage();} -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.blogspot.com http://groups.google.com/group/adwords-api =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en
