Can i build SearchGoogleAdsStreamRequest with many customerIds

47 views
Skip to first unread message

Nguyễn Trọng Quân

unread,
Mar 25, 2024, 5:22:00 AM3/25/24
to Google Ads API and AdWords API Forum
try {
$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();

$query = 'SELECT
campaign.status,
campaign.primary_status,
campaign.optimization_score,
campaign_budget.period,
campaign_budget.total_amount_micros,
campaign_budget.reference_count,
campaign_budget.amount_micros,
metrics.clicks,
FROM campaign WHERE customer.id IN (5717091635, 8411454788)';

$stream = $googleAdsServiceClient->searchStream(
SearchGoogleAdsStreamRequest::build("", $query)
);

foreach ($stream->iterateAllElements() as $googleAdsRow) {
$campaignData = [
'id' => $googleAdsRow->getCampaign()->getId(),
'name' => $googleAdsRow->getCampaign()->getName(),
'status' => $googleAdsRow->getCampaign()->getStatus(),
'primary_status' => $googleAdsRow->getCampaign()->getPrimaryStatus(),
'optimization_score' => $googleAdsRow->getCampaign()->getOptimizationScore(),
'customer' => [
'id' => $googleAdsRow->getCustomer()->getId(),
]
];

$corInit[] = $campaignData;
} can i build SearchGoogleAdsStreamRequest with many customerIds ?

Google Ads API Forum Advisor

unread,
Mar 25, 2024, 11:03:21 AM3/25/24
to qquannguy...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

If you mention multiple client account Id's (CID) in an API request, then also the API returns results for only 1 CID. To retrieve campaigns data for an account, you need to issue separate requests against each client account under the manager account. This means making individual API requests to retrieve data for each client account, kindly note that it's not possible to get data for multiple client accounts in a single query. I would suggest querying API using or specifying a client account Id in customers.googleAds.search method which gives all campaigns data under that particular account. Hope this helps.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02s0CGW:ref" (ADR-00228523)

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages