Re: downloadReportWithAwql returning bad numbers in PHP

2018-03-12 Thread 'Peter Oliquino' via AdWords API Forum
Hi Jay,

In the AdWords API, Money fields 

 such 
as the *Cost* field are represented in micros. So what you're seeing is not 
the actual value of the cost and you will still need to divide it by 
1,000,000 in order to get its actual value. I hope this helps.

Best regards,
Peter
AdWords API Team

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/ed2cd78e-fcae-46df-a1be-094ef000ff8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


downloadReportWithAwql returning bad numbers in PHP

2018-03-11 Thread Jay Chuck Mailen
Hello All,

I've run into an issue and was hoping someone would point me in the right 
direction.

I'm using downloadReportWithAwql (client v201802) to run a query with the 
KEYWORDS_PERFORMANCE_REPORT - it's actually a query we use in an AdWords 
script and it works fine there.

But in the PHP script I'm writing some of the number columns return 
correctly, but others are not.

For example; "Search Impr. share" on one of our keywords is returning 44.83, 
which is correct, but on the same keyword the "Cost" is returning 725 
but the cost is actually 7.25

The cost field isn't the only one doing this. All of these fields are doing 
the same thing: "Avg. CPC", "CPC Bid", "Cost", "CPC" & "Conv. rate" (unless 
their value is 0, in that case it does spit out 0).

All other numeric fields are returning correctly. But these fields return 7 
digits. It appears the whole number separator ( . ) is missing and it's 
cramming all the decimals right into it. (ie x.xx becomes xxx and xx.xx 
also becomes xxx). If it was always one number before the decimal I'd 
just grab the first digit and drop in a decimal, but sometimes it's a value 
like 12.54 becoming 1253267. So that won't work.

Here's a slightly modified version of the code:

private function get_data() {
$reportFormat = DownloadFormat::CSV;
$oAuth2Credential = (new OAuth2TokenBuilder())
->fromFile( self::$ini_path )
->build();

$session = (new AdWordsSessionBuilder())
->fromFile( self::$ini_path )
->withOAuth2Credential( $oAuth2Credential )
->withClientCustomerId( self::$client_id )
->build();

$adWordsServices = new AdWordsServices();
$reportQuery = $this->query( 'KEYWORDS_PERFORMANCE_REPORT' );
/* This is an example of the returned value of $reportQuery
SELECT 
Criteria,CampaignName,AdGroupName,KeywordMatchType,Clicks,Impressions,Ctr,AverageCpc,CpcBid,Cost,AveragePosition,Conversions,CostPerConversion,ConversionRate,SearchImpressionShare,QualityScore
FROM KEYWORDS_PERFORMANCE_REPORT
WHERE 
IsNegative = FALSE
AND Status = ENABLED
AND AdGroupStatus = ENABLED
AND CampaignStatus = ENABLED
DURING 20170911,20180309
*/

$reportDownloader = new ReportDownloader( $session );

$reportSettingsOverride = ( new ReportSettingsBuilder() )
->includeZeroImpressions( false )
->build();

$reportDownloadResult = $reportDownloader->downloadReportWithAwql(
$reportQuery,
$reportFormat,
$reportSettingsOverride
);

return $reportDownloadResult->getAsString();
}


This is an example of what it's kicking out:


"KEYWORDS_PERFORMANCE_REPORT (Sep 11, 2017-Mar 9, 2018)"
Keyword,Campaign,Ad group,Match type,Clicks,Impressions,CTR,Avg. CPC,Max. 
CPC,Cost,Avg. position,Conversions,Cost / conv.,Conv. rate,Search Impr. 
share,Quality score
keyword1,campaign1,group1,Broad,2,127,1.57%,1589,500,3178,2.2,0.00,0,0.00%,59.71%,5
keyword2,campaign2,group2,Broad,2,26,7.69%,2745000,488,549,2.3,0.00,0,0.00%,89.47%,6


Obviously I switched out the keywords, campaigns and ad group names. But 
what's going on with the 7 digit numerical values?

If anyone can shed any light on this and steer me in the right direction I 
would greatly appreciate it. I don't have much hair left and you'd be 
saving me from pulling what little remains out.

Thanks,
-Jay



-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/1d12b842-7ba2-4cc7-a9da-0681d8ba929a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.