Get 0 for cost_micros in query

52 views
Skip to first unread message

Vladimir Hiuk

unread,
Jun 24, 2022, 9:07:45 AM6/24/22
to Google Ads API and AdWords API Forum
Hello,
I need to get all cost_micros for a certain period. In the query below, I get all the data for the period I specified, but there is one problem. In the event that there were no clicks on a certain day, i.e. nothing was spent, I need to get 0. That is, if the period spans 20 days, then I want to get 20 values, some of which may be equal to 0. Now, in this case, I get, for example, 18 values ​​for 20 days, and then I can't match dates and expenses. I don't want to make separate queries for each date as some periods can span 5-7 years.

$query = "SELECT campaign.name, campaign.start_date, campaign.end_date, metrics.cost_micros, segments.date FROM campaign
WHERE segments.date >= " . "'" . $startDate . "'" . "
AND segments.date <= " . "'" . $endDate . "'" . "
AND campaign.id IN (".implode(', ',$campaignIds).") ORDER BY campaign.id";

Google Ads API Forum Advisor

unread,
Jun 24, 2022, 10:53:54 AM6/24/22
to khi...@gmail.com, adwor...@googlegroups.com
Hi Vladimir,

Thank you for reaching out to the Google Ads API support team.

To investigate the issue further, could you please provide the complete request and response logs, with the request-id? If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link.You can provide it via Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead. Let me know if you have any questions.

Thanks,
Google Logo
Nirmitabahen Gaurav
Google Ads API Team
 


ref:_00D1U1174p._5004Q2cCahJ:ref

Vladimir Hiuk

unread,
Jun 27, 2022, 4:26:53 AM6/27/22
to Google Ads API and AdWords API Forum
Hi,

I am unable to get the data you requested. But I don't think they are necessary. I don't have an error in the query, I'm just wondering if I can get 0 as an answer for dates with costs equal to 0. For example, for one of the campaigns for a period of 180 days, I get only 11 values, since there were only 11 days with costs. But can I get all 180 elements of which 169 will be 0 and the other 11 will have a value? I need it to build a graph with dates.
пятница, 24 июня 2022 г. в 16:53:54 UTC+2, adsapi:

Google Ads API Forum Advisor

unread,
Jun 27, 2022, 8:00:09 AM6/27/22
to khi...@gmail.com, adwor...@googlegroups.com
Hi Vladimir,

Thank you for the reply.

Moving forward, Please note that it is currently not possible to force return a row if all selected metrics fields are zero. However, if there's one or more selected metrics fields having a value that is not zero, the row should be returned. You can refer to this documentation for more details.

Best regards,
Google Logo
Heidi
Google Ads API Team
 

 

ref:_00D1U1174p._5004Q2cCahJ:ref
Reply all
Reply to author
Forward
0 new messages