Retrieve campaign name and adgroup name for all keywords?

354 views
Skip to first unread message

Aditya

unread,
Apr 9, 2015, 4:40:25 PM4/9/15
to adwor...@googlegroups.com
So if I understand the examples and documentation correctly, the following bit of code should be a pretty efficient way to retrieve all the keywords (criterion? as the technical term I guess) within a campaign:

Selector selector = builder.fields("Id", "AdGroupId", "KeywordMatchType", "KeywordText").orderAscBy("AdGroupId").offset(offset).limit(PAGE_SIZE).in("CampaignId", campaignID.toString()).equals("CriteriaType", "KEYWORD").build();

Note that I've passed in a Long campaignID. Then you have an adGroupCriterionService get the selector, and then use AdGroupCriterionPage to go through all the AdGroupCriterion results. My question is whether there is an efficient way to retrieve the campaign name and ad group name for each keyword (I want to build a large json object that looks like {"keyword":"text" , "adGroupName" : "name" , "campaignName":"name" } , { keyword ... } etc.)

I current make one API call as shown above that gets all the keywords in a campaign. But then it seems that I have to make individual get requests for each keyword to get its adgroup name and its campaign name (this part is accomplished with an AdGroupService, that returns an AdGroup object when looking up an AdGroupId.) The problem is that doing the AdGroup lookup for each keyword (since the criterion result only lets you get an adgroupID, not an adGroupName), means that we'll be making an API call for each keyword. Obviously this is very expensive and it's causing us to hit our API usage limit (basic access).

Please let me know if I've missed something. Essentially I want to retrieve campaign name, ad group name, and keyword text for all keywords in a campaign. It seems relatively easy to get the IDs for some of these, but my understanding is that it'll take thousands of API calls to get the names from IDs if the client has thousands of keywords.


Josh Radcliff (AdWords API Team)

unread,
Apr 9, 2015, 4:57:32 PM4/9/15
to adwor...@googlegroups.com
Hi,

For your use case, I'd highly recommend looking into using Structure Reports instead. For example, you could run a KEYWORDS_PERFORMANCE_REPORT to quickly pull all of the fields you mentioned in a single request.

Cheers,
Josh, AdWords API Team

Aditya

unread,
Apr 9, 2015, 5:25:56 PM4/9/15
to adwor...@googlegroups.com
Thanks so much, I completely missed the Reporting section! This definitely makes things easier.
Reply all
Reply to author
Forward
0 new messages