Calcucations of account ballance remainder through API gives wrong result and not match UI

68 views
Skip to first unread message

Eduard Gan

unread,
Mar 26, 2018, 6:26:17 AM3/26/18
to AdWords API Forum
Hello everyone.

When i login into my client's account i see the zero amount of availible funds but when i try to get remainder through API i got -9568,58! Furthermore when i download account_actitivies csv report i see in Total spent value of 71980.88 while in reply from api i got 81527.25. the "spent" from API is considerably higher so results calculated from API totally not match results from UI and report.

How i calculate reminders with API, in short : (paid - spend)

def get_paid(client, customer_id):

    query
= {
       
'service': 'BudgetOrderService',
       
'selector': {
           
'fields': ['SpendingLimit'],
       
}
   
}

    billing_accounts
= run_query(client, customer_id, query=query)

    paid
= 0
   
for account in billing_accounts['entries']:
        paid
+= account['spendingLimit']['microAmount'] / 1000000
   
return paid

minus

def get_spent(client, customer_id):
    query
= '''
            SELECT CampaignId, Cost, CampaignStatus, Amount
            FROM CAMPAIGN_PERFORMANCE_REPORT
            '''

   
for row in run_awql(client, customer_id, query):
       
if row['Campaign ID'] == 'Total':
           
return round(int(row['Cost']) / 1000000, 2)


As a result i usually get pretty precise and realistic results. But in case of this customer with customer_id 5668060624 i got this bizarre minus over 9000.

I asked a question about that in technical support - their answer in short was that this strange data deviations might occured of possible refunds.

I still have no way to get the correct result whatever reason data deviated. May be my method of calculations is wrong, please give an advise, thanks!

Milind Sankeshware (AdWords API Team)

unread,
Mar 26, 2018, 2:45:26 PM3/26/18
to AdWords API Forum
Hi Eduard,

Could you please confirm are you checking report stats in AdWords UI? If yes, please share the screenshot of UI where you are comparing the stats. Also, please share the date range for fetched report so that I can troubleshoot the issue.

Thanks,
Milind, AdWords API Team.

Eduard Gan

unread,
Mar 27, 2018, 2:03:27 AM3/27/18
to AdWords API Forum

Hi, Milind.
Daterange - whole. Yes the report i'm talking about is downloaded from AdWords web-UI. Here the screenshots i've made, first from API and then WEB:
API:


WEB_1


WEB_2



Milind Sankeshware (AdWords API Team)

unread,
Mar 27, 2018, 2:43:45 PM3/27/18
to AdWords API Forum
Hi Eduard,

For client customer id 5668060624, I ran the campaign performance report and the cost stats are matching with the total cost from AdWords UI under the campaign section. The cost in activity_report( WEB_2 attached file) might be different from cost fetch by API. You could also refer this guide to maps the AdWords campaign reports stats with AdWords UI. Let me know if you have further questions. 

Eduard Gan

unread,
Mar 28, 2018, 1:16:34 AM3/28/18
to AdWords API Forum


вторник, 27 марта 2018 г., 23:43:45 UTC+5 пользователь Milind Sankeshware (AdWords API Team) написал:
Hi Milind,


For client customer id 5668060624, I ran the campaign performance report and the cost stats are matching with the total cost from AdWords UI under the campaign section. The cost in activity_report( WEB_2 attached file) might be different from cost fetch by API. You could also refer this guide to maps the AdWords campaign reports stats with AdWords UI. Let me know if you have further questions. 

Thanks,
Milind, AdWords API Team.

I can confirm that campaign performance report data absolutely match the representation in UI. No questions here.

I searched mapping guide you've mentioned above but couldn't find a way to get the data from activity_report.

So my next call for help :) is "how do i get programmaticaly data from activity_report" to use them in my calculations because it seems like campaign performance report data is correct but not relevant to my task.

Milind Sankeshware (AdWords API Team)

unread,
Mar 28, 2018, 2:34:32 PM3/28/18
to AdWords API Forum
Hi,

I am afraid, the activity_report is not available in AdWords API. The listed reports are the only reports which are supported by AdWords API. Let me know if you have further questions.

Eduard Gan

unread,
Mar 29, 2018, 2:34:06 AM3/29/18
to AdWords API Forum
Good day!

Thanks for your reply.

Ok, then can you give an advice?

Can i treat as a (roughly) null account budget remainder, situation where i've got any(-1 or -9001 no matters ) negative result during substraction (campaign performance total) from (budget order total).

Milind Sankeshware (AdWords API Team)

unread,
Mar 29, 2018, 3:59:48 PM3/29/18
to AdWords API Forum
Hi Eduard,

Could you please elaborate your question 'Can i treat as a (roughly) null account budget remainder'?

Eduard Gan

unread,
Mar 30, 2018, 1:39:51 AM3/30/18
to AdWords API Forum
пятница, 30 марта 2018 г., 0:59:48 UTC+5 пользователь Milind Sankeshware (AdWords API Team) написал:

Hi Milind,

Of cource. I tried to say - can for me any negative result of substraction described above(sum of budgetorders minus total cost of all campaign performance) be a sign that account's amount of money is depleeted and so no ads from activated campaigns can be showed up and i can alert the user with email about that?

For now in current variant i'm alerting a client with -9xxx account ballance info, He logs in and see ballance info, that show just 0 and then he asks me "why you scaring me with this bizarre ballance when i see in my personal account that ballance is just 0 which is ok."

Eduard Gan

unread,
Mar 30, 2018, 1:54:01 AM3/30/18
to AdWords API Forum


Just added an additional screenshot to illustrate what my client sees.

Milind Sankeshware (AdWords API Team)

unread,
Mar 30, 2018, 4:00:37 PM3/30/18
to AdWords API Forum
Hi Eduard,

Thanks for sharing the details. Usually, if you find that the total cost of all campaigns 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. If you are referring the values from AdWords UI or looking for the values from activity_report which is downloaded from AdWords UI, I would recommend to post your questions on AdWords Community forum. Let me know if you have further questions.

Eduard Gan

unread,
Apr 2, 2018, 8:51:21 AM4/2/18
to AdWords API Forum
Hi Milind, thank you very much for your help. I'm marking this thread as solved.
Reply all
Reply to author
Forward
0 new messages