Skip Removed Adgoups, KeyWords, and Text Ads?

81 views
Skip to first unread message

Edward Bernays

unread,
Feb 13, 2018, 12:15:04 PM2/13/18
to AdWords API Forum
Can tell the API to ignore removed adgroups/keywords/text when I do a get call? My script was fast, but it's starting to take a really long time as it appears to be going through all removed items in my campaign.

Dhanya Sundararaju (AdWords API Team)

unread,
Feb 13, 2018, 3:56:02 PM2/13/18
to AdWords API Forum
Hi Edward,

To get the removed AdGroups, Keywords and Ads, you can use the AdGroupServiceAdGroupCriterionService and AdGroupAdService respectively. Then, use the selector fields to filter by status for AdGroups and Ads; and by userStatus for keywords.

Sample code snippet in java for AdGroup is as below:
Selector selector = builder
        .fields(AdGroupField.Id, AdGroupField.Name, AdGroupField.Status)
        .orderAscBy(AdGroupField.Name)
        .offset(offset)
        .limit(PAGE_SIZE)
        .equals(AdGroupField.Status,"REMOVED")
        .build();

Please let me know if you have further questions.

Regards,
Dhanya, AdWords API Team

Edward Bernays

unread,
Feb 14, 2018, 9:46:52 AM2/14/18
to AdWords API Forum
Hi Dhanya,

I was wondering if it was possible for the API to ignore removed keywords & adgroups. I have over 100,000 removed keywords and it's slowing down my script.

Dhanya Sundararaju (AdWords API Team)

unread,
Feb 14, 2018, 4:35:44 PM2/14/18
to AdWords API Forum
Hi Edward,
For your code to ignore removed adgroup and keywords, you would need to use predicates in your selector as below:

// For AdGroups
    // Create selector.
    SelectorBuilder builder = new SelectorBuilder();
    Selector selector = builder
        .fields(AdGroupField.Id, AdGroupField.Name, AdGroupField.Status)
        .orderAscBy(AdGroupField.Name)
        .offset(offset)
        .limit(PAGE_SIZE)
        .in(AdGroupField.Status,"ENABLED","PAUSED")
        .build();

//For Keywords
    // Create selector.
    SelectorBuilder builder = new SelectorBuilder();
    Selector selector = builder
        .fields(
            AdGroupCriterionField.Id,
            AdGroupCriterionField.CriteriaType,
            AdGroupCriterionField.AdGroupId,
            AdGroupCriterionField.Status
            )
        .orderAscBy(AdGroupCriterionField.KeywordText)
        .offset(offset)
        .limit(PAGE_SIZE)
        .in(AdGroupCriterionField.AdGroupId, adGroupId.toString())
        .in(AdGroupCriterionField.CriteriaType, "KEYWORD")
        .in(AdGroupCriterionField.Status, "ENABLED", "PAUSED")
        .build();
Reply all
Reply to author
Forward
0 new messages