Get account budgets

195 views
Skip to first unread message

Marketing Xilon

unread,
Nov 2, 2016, 6:15:48 AM11/2/16
to AdWords API Forum
Hi,

how can I get account budgets via API? I'm confused about the different terms used on the docs (Budget, BudgetOrder...)
Also, I don't see status on BudgetOrder. How can I retrieve it?

Thanks

Shwetha Vastrad (AdWords API Team)

unread,
Nov 2, 2016, 12:14:24 PM11/2/16
to AdWords API Forum
Hi,

To retrieve your account budgets, you need to use BudgetOrderService. A BudgetOrder is an authorization for a client account to spend a certain amount of money over the specified period of time. This spend is accrued onto the given billing account. A Budget on the other hand is used to manage the amount of money spent on your campaigns. A budget can apply to a single campaign, or shared across many campaigns. 

The BudgetOrder contains a lastRequest field that includes information about the status of the request. To You can check the endDateTime field to determine if a BudgetOrder has ended. Please note that BudgetOrderService is available only to whitelisted AdWords manager accounts. 

Regards,
Shwetha, AdWords API Team.

Marketing Xilon

unread,
Nov 3, 2016, 7:34:43 AM11/3/16
to AdWords API Forum
Thank you for your detailed explanation Shwetha.

I can already get BudgetOrders via BudgetOrderService (my account is whitelisted). My question now is how to get the spend amount of each BudgetOrder? Should I get the associated campaigns and check Cost?

By the other hand, I am including LastRequest on the selector fields but params like startDateTime, endDateTime, date are empty on the returned object. What am I missing?

Thanks

Shwetha Vastrad (AdWords API Team)

unread,
Nov 3, 2016, 12:49:27 PM11/3/16
to AdWords API Forum
Hi,

I'm afraid BudgetOrder spend is not available through the API. One way to get this information is to get the total cost accrued for this account using Account Performance Report in the duration during which the BudgetOrder was active and subtract this value from the spendingLimit of the BudgetOrder. 

The LastRequest field contains the last set of values that were passed in through the parent BudgetOrder for mutate.add and mutate.set. If you did not change the startDateTime or endDateTime in the previous request, these fields may be empty. If that's not the case, could you provide the complete SOAP request and response logs so I can further investigate? Please use Reply privately to author when responding. 

Marketing Xilon

unread,
Nov 7, 2016, 1:27:43 PM11/7/16
to AdWords API Forum

Hi, 

thank you for your help.
Following your recommendation, I am trying to get the cost using Account Performance Report for each account budget, but it shows different amounts than the Adwords Account budgets view.

This is how UI looks:


First budget (Jun 16, 2016 - Jul 1, 2016) spend 76.26€ which is different to 79.25€, the amount I get on the report for those dates.

This is the PHP function for getting the account cost during dates:

function GetAccountTotalCost(AdWordsUser $user, $dateRange) {

    $options = array('version' => ADWORDS_VERSION);
    $options['skipReportHeader'] = true;
    $options['skipColumnHeader'] = true;
    $options['skipReportSummary'] = false;

         $reportQuery = 'SELECT AccountCurrencyCode, Cost '
        . 'FROM ACCOUNT_PERFORMANCE_REPORT '
        . 'DURING ' . $dateRange;

    // Download report.
    $reportUtils = new ReportUtils();
    $reportString = $reportUtils->DownloadReportWithAwql($reportQuery, null, $user, 'CSV', $options);

    $reportArray = array_filter(explode("\n", $reportString));
    $reportSummary = explode(",",end($reportArray));

    $totalCost = $reportSummary[1] / 1000000;

    print('Date '.$dateRange.' Cost='.$totalCost."\n");

}

That returns:

Date 20160616,20160701 Cost=79.25

What am I missing?
Thank you!

Shwetha Vastrad (AdWords API Team)

unread,
Nov 7, 2016, 3:15:38 PM11/7/16
to AdWords API Forum
Hi, 

Could you provide the clientCustomerId for this account? I see that the difference is $0.01. When gauging your account performance, please note that some recent account data may not be showing up yet. Some statistics are continuously calculated, while others are calculated once a day. To use reporting effectively, please refer to the data freshness documentation. 

Marketing X

unread,
Nov 7, 2016, 3:19:30 PM11/7/16
to AdWords API Forum
The customerId is 469-803-7407. This data isn't recent but from several months ago.
Thanks

Shwetha Vastrad (AdWords API Team)

unread,
Nov 7, 2016, 3:52:24 PM11/7/16
to AdWords API Forum
Hi,

I calculated the difference incorrectly. My mistake. Account Performance Report would have the data for when the cost was attributed, which due to some latencies in conversion tracking could be delayed as described in the data freshness guide. The workaround I suggested is one way to get the budget spend since this value is not directly available in the API. One of the reasons for the cost from Account Performance Report to be higher could be overdelivery credit

Marketing X

unread,
Nov 8, 2016, 4:44:51 AM11/8/16
to AdWords API Forum
Thanks for the explanation. Let me ask you something else. 
When running the GetAccountTotalCost function pasted in this message for the same dates of the Account budgets screen (Adwords UI), I get the following differences:

Date 20160616,20160701 API Cost=79.25 UI Cost=76.26
Date 20160701,20160718 API Cost=77.01 UI Cost=75.00
Date 20160921,20161010 API Cost=82.33 UI Cost=74.25
Date 20161010,20161105 API Cost=74.25 UI Cost=74.25

So should I assume that even when API cost is higher than budget amount, the account budget spend is 100% and status Ended? 
Thank you

Shwetha Vastrad (AdWords API Team)

unread,
Nov 8, 2016, 2:11:18 PM11/8/16
to AdWords API Forum
Hi, 

I checked this account and found that the total cost matches for the duration of June 16, 2016 to November 5, 2016. But it looks like it doesn't line up with individual budget orders. It could be because the time at which reports are generated is different from the time during which the budget orders were active. 

Usually, if you find that the total cost is greater that the spendingLimit of the active budget order, you can consider the budget order to be exhausted or nearly exhausted. Please note that this doesn't take into account overdelivery credit
Reply all
Reply to author
Forward
0 new messages