Retrieving data from multiple customers in one query

172 views
Skip to first unread message

Teun vh

unread,
Aug 22, 2022, 5:11:21 AM8/22/22
to Google Ads API and AdWords API Forum
Hi, 

In our current code we retrieve metrics per customer in a single query.
However because our client database grows we sometimes want to retrieve metrics like impressions for all our clients together in one call. 
Is this possible?

Current example code:
public static function runExample(GoogleAdsClient $googleAdsClient, int $customerId)
{
    $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
    // Creates a query that retrieves keyword statistics.
    $query =
        
"SELECT metrics.impressions, metrics.clicks FROM campaign WHERE segments.date DURING LAST_30_DAYS";

    // Issues a search stream request.
    /** @var GoogleAdsServerStreamDecorator $stream */
    $stream = $googleAdsServiceClient->searchStream($customerId, $query);



In the example above we have to send a customerId for each customer and a request is made per customer. We would like to send an array of customer ids and make a query that requests this metrics in one call.

Thanks in advance!

Google Ads API and AdWords API Forum

unread,
Aug 24, 2022, 1:45:33 AM8/24/22
to Google Ads API and AdWords API Forum
Re-posting the last inquiry ( https://groups.google.com/g/adwords-api/c/nv214XIPoXo ) from the forum as it wasn't routed to our support queue.

Kind regards,
Sherwin Vincent
Google Ads API Team

Google Ads API Forum Advisor

unread,
Aug 24, 2022, 7:50:40 AM8/24/22
to adwor...@googlegroups.com
Hi,

Thank you for posting your concern. Allow me to provide support to your concern.

With regard to your concern, I am afraid that this is not possible. The metrics fields of the Google Ads API reporting can only be requested on a client account only. With this, I would suggest continuing using the current implementation.

The other way is to loop the current implementation to accommodate the array of customer Ids.

Let me know if you have further questions.

Regards,
Google Logo
Ernie John
Google Ads API Team
 


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