ReportDefinition "Cost" field format change?

1,092 views
Skip to first unread message

stiggywigget

unread,
Jul 5, 2014, 9:59:29 PM7/5/14
to adwor...@googlegroups.com
Cost field is a decimal value "7.44" in XML format for API v201309 (PHP)
Cost field is a integer value "7440000" in XML format for API v201402 (PHP)

I haven't found an explanation for this change.

TIA.

Jean-Fabrice Rabaute

unread,
Jul 6, 2014, 8:55:25 AM7/6/14
to adwor...@googlegroups.com
The money fields are returned in micro starting with v201402 API:


Starting with v201402, fields of type Money are returned in micro currency units (micros) by default, e.g.: $1.23 will come back as 1230000 (1.23 x 1,000,000). The header value that determines whether money fields are returned in micros or whole dollar (1.23) currency units is returnMoneyInMicros; setting this to true (default) selects micros. Micro amounts always refer to the account's local currency.


Hope this helps.

Cheers.

--
Fabrice.
https://www.sunnyreports.com/

stiggywigget

unread,
Jul 6, 2014, 12:14:00 PM7/6/14
to adwor...@googlegroups.com
The docs clearly state that for a CAMPAIGN_PERFORMANCE_REPORT field "Cost" is type Money.

$user->LoadService('ReportDefinitionService', ADWORDS_VERSION);

// Create selector.
$selector = new Selector();
$selector->fields = array('CampaignId', 'CampaignName', 'Status', 'Clicks', 'Cost', 'Date');

// Report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->reportName = 'Report';
$reportDefinition->dateRangeType = 'LAST_7_DAYS';
$reportDefinition->reportType = 'CAMPAIGN_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'XML';
$reportDefinition->selector = $selector;

$xml_data = DownloadReport($user, $reportDefinition);

For v201309:
    <row campaignID='1234' campaign='Cmp Name' campaignState='active' clicks='15' cost='40.24' day='2014-06-30' />

For v201402:
    <row campaignID='1234' campaign='Cmp Name' campaignState='active' clicks='15' cost='40240000' day='2014-06-30' />

Please help!

stiggywigget

unread,
Jul 6, 2014, 12:21:19 PM7/6/14
to adwor...@googlegroups.com
Minor correction. 
$xml = ReportUtils::DownloadReport($reportDefinition, $filepath = NULL, $user, NULL);

Oliver

unread,
Jul 7, 2014, 1:44:54 AM7/7/14
to adwor...@googlegroups.com
In the v201402 release notes:

there is a section that says:

ReturnMoneyMicros defaults to true

Money fields will be returned in micros by default. You can enable the old behavior by sending the ReturnMoneyMicros header with the value of false. Note: This field will be removed in the future.

Maybe that's what happened?

Oliver

Danial Klimkin

unread,
Jul 7, 2014, 4:35:29 AM7/7/14
to adwor...@googlegroups.com
Oliver is correct, this has been changed as outlined on the release notes and in the migration guide:


For v201402 you can send "returnMoneyInMicros: false" to see the old behavior. In the next API version this header will no longer be valid, so we recommend migrating to micros as soon as possible.


-Danial, AdWords API Team.

stiggywigget

unread,
Jul 7, 2014, 7:47:11 AM7/7/14
to adwor...@googlegroups.com
Thanks all. Obviously the change was well documented.

-Kirk
Reply all
Reply to author
Forward
0 new messages