Trying to Make ACCOUNT_PERFORMANCE_REPORT

512 views
Skip to first unread message

Ron Jacobson

unread,
May 5, 2011, 5:51:06 PM5/5/11
to AdWords API Forum
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!!

jstedman

unread,
May 5, 2011, 8:36:30 PM5/5/11
to AdWords API Forum
Ron,

Imps is not a valid field for the ACCOUNT_PERFORMANCE_REPORT, neither
is Spend actually. Your printout of the field listing is incomplete,
but I am assuming that the rest of it just didn't make it to the
forum. For quick reference you could always use this page:

http://code.google.com/apis/adwords/docs/appendix/reports.html#account

I'm pretty sure getting the list of supported fields through the API
itself is more likely to stay up to date, but I have not had a problem
with that listing yet. The save to csv file helps too.

Ron Jacobson

unread,
May 6, 2011, 10:53:49 AM5/6/11
to AdWords API Forum
Thanks for the response. I took what you said into account and changed the file as follows (Date,Cost,Impressions) and I'm getting the same result:

<?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) 'HIDDEN';
  $startDate = '20110501';
  $endDate = '20110502';
  $selector = new Selector();
  $selector->fields = array('Date','Impressions','Cost');
  $selector->dateRange = new DateRange($startDate, $endDate);
v201101$ php AddAccountPerformanceReport.php 
ReportDefinitionError.INVALID_FIELD_NAME_FOR_REPORT @ AdGroupIdDev~14:48:18 v201101$ 

Any help would be appreciated
---------------------------------

jstedman

unread,
May 7, 2011, 10:09:43 AM5/7/11
to AdWords API Forum
$reportDefinition->dateRangeType = 'YESTERDAY';

does not support

$selector->dateRange = new DateRange($startDate, $endDate);

try not setting the dateRange for the selector, not that it makes
sense for INVALID_FIELD_NAME_FOR_REPORT to be the error returned, but
it's the only thing I am seeing that doesn't look right.

in order to use an absolute date range you have to use dateRangeType =
"CUSTOM_DATE", but if you want to run this report for YESTERDAY all
the time, you can generate one report using that date range type and
the date range will "slide" as time goes on. Once you have the
reportID for a sliding date range report, you no longer have to use
the report definition service, you can just make the http request for
the report and it will no longer cost you any units, so setting an
explicit date range here would just cost more in the end. There is no
good documentation about how Google will be storing reportIDs and for
how long they will be valid, and how many you can store with a single
account, so ideally the code should be able to handle the http
responses that are listed towards the bottom of this page :
http://code.google.com/apis/adwords/docs/reportingtopics.html just in
case a specific reportID is no longer valid.
Reply all
Reply to author
Forward
0 new messages