Get all accounts linked to MCC with Label "BLA"

49 views
Skip to first unread message

Aba

unread,
Sep 29, 2016, 3:41:30 PM9/29/16
to AdWords API Forum
Hi all,

I am trying to retrieve all accounts with label "BLA" that are linked to my MCC .

I have managed to do so by creating the following selector : 

SelectorBuilder selectorBuilder =
       new SelectorBuilder()
           .fields(ManagedCustomerField.CustomerId
            ,ManagedCustomerField.AccountLabels
            ,ManagedCustomerField.Name)
           .offset(offsetMC)
           .limit(PAGE_SIZE);

And then iterating through the output and checking if AccountLabels contained "BLA". 

Is there a better way to specify that in the selector from the get-go ? I could not figure it out.

Thanks for your help ! 

Shwetha Vastrad (AdWords API Team)

unread,
Sep 29, 2016, 4:07:16 PM9/29/16
to AdWords API Forum
Hi,

You can add a predicate to filter only accounts with the specified label in the response. The selector should look like this:

SelectorBuilder selectorBuilder =
        new SelectorBuilder()
            .fields(ManagedCustomerField.CustomerId
             ,ManagedCustomerField.AccountLabels
             ,ManagedCustomerField.Name)
            .equals(ManagedCustomerField.AccountLabels, "AccountLabelId")
                    .offset(offsetMC)
            .limit(PAGE_SIZE);

Regards,
Shwetha, AdWords API Team.

Aba

unread,
Sep 29, 2016, 4:17:00 PM9/29/16
to AdWords API Forum
Hi Shwetha ,

What if I don't know the LabelID before hand , I just know the labelName.

Aba

unread,
Sep 29, 2016, 4:54:16 PM9/29/16
to AdWords API Forum
Also,  selectorBuilder does not work with predicate it seems ???

Shwetha Vastrad (AdWords API Team)

unread,
Sep 29, 2016, 5:01:03 PM9/29/16
to AdWords API Forum
Hi,

You can use AccountLabelService get method to retrieve a list of account labels that are created by this manager account. The response will contain the id and name of the account labels. 

I haven't faced any issues while using SelectorBuilder with predicates. Do you encounter any errors if you use selectorBuilder to add predicates?
Reply all
Reply to author
Forward
0 new messages