BTW: forget to mention I reset the daily budget from 850000 to 1220000 on
2021-10-28
On Thursday, October 28, 2021 at 1:04:26 AM UTC-7 Haiyang Si wrote:
> Hi support team,
>
> As in the image below, I am trying to set the daily budget based on the
> *budget
> left* and the *day left *dynamically.
>
> Is there an easy way to get the *Cost within spending limit* or *Budget
> left* for a campaign?
>
> [image: Screen Shot 2021-10-28 at 12.35.03 AM.png]
>
> Currently, I do it in this way:
> 1. get the start_date of a campaign
> 2. query the metrics.*cost_micros* from *start_date* until *today*
> query = f"""
> SELECT
> campaign_budget.amount_micros,
> campaign_budget.total_amount_micros,
> metrics.cost_micros,
> FROM
> campaign_budget
> WHERE
> campaign.id = 123456
> AND segments.date = '{input_date}'
> """
>
> 3. Because *metrics.cost_micros *is the "*served cost"* I have to
> calculate the real cost like this: real_cost = min(metrics.cost_micros,
> 2*campaign_budget.amount_micros)
> 4. Sum the *real_cost* in every day up as the "*Cost within spending
> limit"*.
>
>
> But in this way, there is a bug.
> Google query campaign_budget.amount_micros always returns the current
> daily_budget value, even the segments.date set on another day.
> E.g. in the image below, on Oct, 26, 2021, the
> campaign_budget.amount_micros should be 850000, but the return value is
> amount_micros:
> 1220000 even the segments.date = '2021-10-25'.
> 1220000 is the current daily_budget.
>
> [image: Screen Shot 2021-10-28 at 12.57.43 AM.png]
>
> In summary there are 1 question and 1 issue to report:
> 1. How to get the budget left or cost within spending limit easily?
> 2. There is a potential bug when query campaign_budget.amount_micros.
> The return value is different from the value on segments.date date
>
> Looking forward to your response.
> Thank you!
>
> Haiyang
>
>
>
>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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
"AdWords API and Google Ads 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/3feabcca-0494-4004-99af-8f25a5ec54aen%40googlegroups.com.