how to get Label Values PHP

92 views
Skip to first unread message

FMore

unread,
Feb 4, 2022, 6:09:47 AM2/4/22
to Google Ads API and AdWords API Forum
Hi

i am trying to get all labels of a customer, here is my code

 $query = ' SELECT customer_client.id, customer_client.descriptive_name, customer_client.applied_labels,
customer_client.client_customer
FROM customer_client';

$response = $googleAdsServiceClient->search($customerId, $query); foreach ($response->iterateAllElements() as $googleAdsRow) { /** @var GoogleAdsRow $googleAdsRow */ $customer = $googleAdsRow->getCustomerClient(); $customerId = $customer->getId(); $customerName = $customer->getDescriptiveName(); $customerLabels = $customer->getAppliedLabels(); var_dump($customerId); var_dump($customerName); var_dump($customerLabels); }

CustomerId and name is retuens the correct value.The problem is that $customerLabels is empty. But this customer have more then 20 labels.
What i am doing wrong?

Thanks





Google Ads API Forum Advisor

unread,
Feb 4, 2022, 11:25:14 AM2/4/22
to filipem...@gmail.com, adwor...@googlegroups.com
Hi,

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

With regards to your concern, you can use coustomer_label resource return the applied label to the customer_id specified in your API request  and use the label(customers/{customer_id}/labels/{label_id}) value to map  resource_name in label resource to get label.name. Let me know if you have any question.

Thanks,
Google Logo
Nirmita Patel
Google Ads API Team
 


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