How to get a spend(cost) for the last month or specified month data only in PHP

739 views
Skip to first unread message

Anil Chaudhary

unread,
Nov 2, 2022, 6:35:44 AM11/2/22
to Google Ads API and AdWords API Forum
Hello Team,

can you please let me know how to get Main manager account of Multiplies customer account of multiple campaign of spend cost for example 1st oct to 31st oct.

I have to get all those data and set those all the data into my Laravel built website admin panel where admin show that all the data according to customer wise spend cost.

PHP: 7.4
Laravel version : 6
Please help me about this to get result.

Google Ads API Forum Advisor

unread,
Nov 2, 2022, 3:24:49 PM11/2/22
to accha...@netclues.com, adwor...@googlegroups.com
Hi Anil,

Thank you for raising this concern to the Google Ads Forum.

With regard to your concern, if you want to get the cost or spend metric in the Google Ads API, then I would suggest using the campaign report and include the metrics.cost_micros field.

If you want to download the campaign report with the cost for multiple accounts in parallel, you may use this Parallel Report Download sample code in PHP. Let me know if this is what you are looking for. 

Best regards,
Google Logo
Jinky
Google Ads API Team
 


ref:_00D1U1174p._5004Q2fqqv2:ref

Anil Chaudhary

unread,
Nov 3, 2022, 6:51:21 AM11/3/22
to Google Ads API Forum Advisor, adwor...@googlegroups.com
Hello Team,

I want to get those costs from the Performance tab  -> Account name of the cost

Please check the attached images screenshot that we have set the RED line to the data I want to get from a given date like 1st oct to 31st oct with all the account name and cost.

Thank you.

Thanks & Regard's,
Anil Chaudhary
PHP Developer

image_2022_11_02T09_40_22_332Z.png

Google Ads API Forum Advisor

unread,
Nov 3, 2022, 12:31:14 PM11/3/22
to accha...@netclues.com, adwor...@googlegroups.com
Hi Anil,

Thank you for the clarifications. 

Upon checking the provided screenshots, it appears that you want to get the cost at the account level. With this, you may use instead the customer report and include the metrics.cost_micros field. For your convenience, you may use the query below as the date range you mentioned are considered: 

SELECT metrics.cost_micros, customer.descriptive_name, customer.id FROM customer WHERE segments.date DURING LAST_MONTH

Also, since you want to get the cost of the multiple accounts the Parallel Report Download can still be used in your use case. 

Anil Chaudhary

unread,
Nov 4, 2022, 10:22:23 AM11/4/22
to Google Ads API Forum Advisor, adwor...@googlegroups.com
Thanks for your help.

i will test this query in my live account and let you know if anything.

FYI: PHP Framework for  Parallel Report Download is not available.
Showing this error: "This is not applicable to PHP because multi-threading cannot be used in a web server environment."

Thanks & Regard's,
Anil Chaudhary
PHP Developer

Google Ads API Forum Advisor

unread,
Nov 4, 2022, 11:07:25 AM11/4/22
to accha...@netclues.com, adwor...@googlegroups.com
Hi Anil,

Thank you for your reply.

For the "This is not applicable to PHP because multi-threading cannot be used in a web server environment." message that is being displayed in the documentation for PHP, I would recommend that you raise and consult this with the PHP client library owners instead, via this link, as they should be better equipped in providing guidance and possible workaround or alternatives.

I hope this helps.

Best regards,

Google Logo
Peter Laurence
Google Ads API Team
 


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