To update this, I have made progress and have the Day field now by pulling 
in segments.date as a query field. Thought I had tried that before but for 
whatever reason redoing things got that part working.

I realized I needed to update the query I was using to this:

$query =
                    "SELECT "
                    . "segments.date, "
                    . "metrics.impressions, "
                    . "metrics.clicks, "
                    . "metrics.conversions_by_conversion_date, "
                    . "metrics.conversions, "
                    . "metrics.conversions_value, "
                    . "metrics.cost_micros "
                    . "FROM keyword_view ";

and my date range query would be
$query .= "WHERE segments.date >= '" . $fromDate->format('Y-m-d') . "' AND 
segments.date <= '" . $toDate->format('Y-m-d') . "' ";

Adding this in case it helps anyone else. 

On Tuesday, February 8, 2022 at 4:36:50 PM UTC-5 Derek Piper wrote:

>
> I am trying to convert reporting that was written for AdWords to this 
> Google Ads API. This was written in PHP.
>
> What I used to have was:
>
>  $reportSettings = (new ReportSettingsBuilder())
>                         ->includeZeroImpressions(false)
>                         ->skipReportSummary(true)
>                         ->build();
>
>                 $reportSession = (new AdWordsSessionBuilder())
>                         ->withOAuth2Credential($this->_oauth)
>                         ->withDeveloperToken($this->_authsource[
> 'dev_token'])
>                         ->withReportSettings($reportSettings)
>                         ->withClientCustomerId($accountId)
>                         ->withSoapLogger($this->_adwordsLogger)
>                         ->build();
>
>                 $reportSelector = new Selector();
>                 if (empty($fields))
>                 {
>                     $fields = array('Date', 'Clicks', 'Impressions', 
> 'Cost', 'AveragePosition', 'Conversions', 'ConversionValue');
>                 }
>                 $reportSelector->setFields($fields);
>                 if (!empty($dateFrom))
>                 {
>                     $dateRange = new DateRange();
>                     $fromDate = new \Score\Time($dateFrom['mon'] . '/' . 
> $dateFrom['mday'] . '/' . $dateFrom['year']);
>                     $toDate = new \Score\Time($dateTo['mon'] . '/' . 
> $dateTo['mday'] . '/' . $dateTo['year']);
>                     $dateRange->setMin($fromDate->format('Ymd'));
>                     $dateRange->setMax($toDate->format('Ymd'));
>                     $reportSelector->setDateRange($dateRange);
>                 }
>
> I am having an issue trying to find the correct way to get aggregate 
> information for the fields:
>
> 'Date', 'Clicks', 'Impressions', 'Cost', 'AveragePosition', 'Conversions', 
> 'ConversionValue' 
>
> I have been looking at this: 
> https://developers.google.com/google-ads/api/docs/reporting/example
>
> to help me get there and although it appears to return a lot of data, it 
> is hard to determine exactly what it is since it comes back as the 
> GoogleAdsRow object. When trying to 'getSegments()' from this in order to 
> get the Date field, for example, the object returned is null.
>
> Is there any resource for converting adwords reports to the Google Ads API 
> ? Are there methods to get the Google Ads API to simply return a CSV file 
> of the data I'm wanting?
>
> Help would be appreciated, thanks.
>
> Derek
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads 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
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/1dc663df-6680-4602-9aaa-f50c971c3541n%40googlegroups.com.

Reply via email to