I run the following to see the available fields for an
account_performance_report:


php GetReportFields.php
The report type 'ACCOUNT_PERFORMANCE_REPORT' contains the following
fields:
- AccountCurrencyCode (String)
- AccountDescriptiveName (String)
- AccountTimeZoneId (Integer)
- AdNetworkType1 (AdNetworkType1) := [SEARCH, CONTENT]
- AdNetworkType2 (AdNetworkType2) := [SEARCH, SEARCH_PARTNERS,
CONTENT]
- AverageCpc (Money)
- AverageCpm (Money)
- AveragePosition (Double)
- BudgetLostImpressionShare (Double)
- Clicks (Long)
- ClickType (ClickType) := [URL_CLICKS, CALLS, OTHER,
PRODUCT_EXTENSION_CLICKS, SITELINKS, PRODUCT_LISTING_AD_CLICKS,
GET_DIRECTIONS, OFFER_PRINTS]
- ConversionCategoryName (String)
- ConversionRate (Double)
- ConversionRateManyPerClick (Double)
- Conversions (Long)
- ConversionsManyPerClick (Long)
- ConversionTypeName (String)
- ConversionValue (Long)
- Cost (Money)
- CostPerConversion (Money)
- CostPerConversionManyPerClick (Money)
- Ctr (Double)
- CustomerDescriptiveName (String)
- Date (Date)
- DayOfWeek (DayOfWeek) := [MONDAY, TUESDAY, WEDNESDAY, THURSDAY,
FRIDAY, SATURDAY, SUNDAY]
- Device (DeviceType) := [DESKTOP, HIGH_END_MOBILE]
- ExactMatchImpressionShare (Double)
- ExternalCustomerId (Long)
- HourOfDay (Integer)

The ones I care about are Date,Cost and Impressions. I then make the
following script to try to make a ACCOUNT_PERFORMANCE_REPORT with the
above listed fields.


<?php
error_reporting(E_STRICT | E_ALL);
$path = dirname(__FILE__) . '/../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
try {
  $user = new AdWordsUser();
  $user->LogDefaults();
  $reportDefinitionService = $user-
>GetReportDefinitionService('v201101');
  $adGroupId = (float) '(hiding number)';
  $startDate = '20110501';
  $endDate = '20110502';
  $selector = new Selector();
  $selector->fields = array('Date','Imps','Spend');
  $selector->dateRange = new DateRange($startDate, $endDate);
  var_dump($selector);
  $adGroupIdPredicate = new Predicate('AdGroupId', 'EQUALS',
array($adGroupId));
  $selector->predicates = array($adGroupIdPredicate);
  // Create report definition.
  $reportDefinition = new ReportDefinition();
  $reportDefinition->reportName = "Test Report";
  $reportDefinition->dateRangeType = 'YESTERDAY';
    $reportDefinition->reportType = 'ACCOUNT_PERFORMANCE_REPORT';
  $reportDefinition->downloadFormat = 'CSV';
  $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) {
    foreach ($result as $reportDefinition) {
      printf("Report definition with name '%s' and id '%s' was added.
\n",
          $reportDefinition->reportName, $reportDefinition->id);
    }
  } else {
    print "No report definitions were added.\n";
  }
} catch (Exception $e) {
  print $e->getMessage();
}


When I run, I get the following output:

Dev~21:49:55 v201101$ php AddAccountPerformanceReport.php
ReportDefinitionError.INVALID_FIELD_NAME_FOR_REPORT @ ;
trigger:'Imps'Dev~21:49:58 v201101$


I don't understand why the field names are invalid as the earlier
GetReportFields output included the field names I'm loking for.

Any help that anyone can provide would be great.

Thanks!!

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

Reply via email to