Best practice for report downloading from multiple client accounts inside an MCC account

927 views
Skip to first unread message

Mark Ibanez

unread,
Sep 8, 2013, 4:08:15 AM9/8/13
to adwor...@googlegroups.com
Hi,

Before I state my question, please allow me to describe what I am trying to accomplish and how I am currently implementing it. I am downloading reports from multiple accounts (different ClientCustomerIDs) from an MCC account. I use Adhoc Reports within C# (.Net Library) to do this.

I already have a working code to do this. The logic for this is as follows:

1. Create an AdWordsUser object
2. Set AdWordsUser.Config.ClientCustomerId to the MCC Account's ClientCustomerId
3. Retrieve the list of accounts inside an MCC Account using the following classes: ManagedCustomerService, ManagedCustomerPage, ManagedCustomer
4. Iterate through the ManagedCustomerPage.entries array
4a. Get ManagedCustomer object from array
4b. Parse ManagedCustomer.customerID value to ClientCustomerId format (eg. 123-456-7890)
4c. Set AdWordsUser.Config.ClientCustomerId to parsed ManagedCustomer.customerID value
4d. Get report using ReportUtilities.GetClientReport() method
4e. Process the report data and append to combined reports

The above logic works fine although I think it is a bit inefficient in terms of API calls. When using this logic, the number of API calls is 1 + n, where n equals the number of accounts inside an MCC account. For example, if the MCC account contains 10 client accounts, the number of API calls needed is 11.

So here's my question. Is there a more efficient way to accomplish the logic described above using less API calls (1 API call would be ideal)? 

I look forward to your answers. Thank you in advance for any help.

Best regards,

Mark Ibanez

Anash P. Oommen (AdWords API Team)

unread,
Sep 10, 2013, 1:04:32 PM9/10/13
to adwor...@googlegroups.com
Hi Mark,

Your approach is the recommended one, since AdWords API reports don't support MCC level reports. However, you can go for the following improvements.

1. Put 4c, 4d, 4e in a thread of its own. The thread method accepts the clientCustomerId as argument. Create a new AdWordsUser, set its Config.ClientCustomerId in the thread and then make calls.
2. Limit the number of threads to about 20. 
3. Expect that you may get RateExceededErrors. So put your report download code in a try-catch loop with exponential backoff algorithm.
4. Increase HTTP connnection settings in your code appropriately, so that .NET runtime doesn't throttle your connections. Something like:

ThreadPool.SetMinThreads(100, 4);
System.Net.ServicePointManager.DefaultConnectionLimit = 100;

Cheers,
Anash P. Oommen,
AdWords API Advisor.

Mark Ibanez

unread,
Sep 13, 2013, 3:01:04 AM9/13/13
to adwor...@googlegroups.com
Thank you very much Anash. 

Best regards,

Mark

Amit Pawar

unread,
Sep 30, 2014, 11:35:48 AM9/30/14
to adwor...@googlegroups.com
How you would do in Java ? Do we have the sample program to do so ?

Amit Pawar

unread,
Oct 1, 2014, 10:02:39 AM10/1/14
to adwor...@googlegroups.com
Any updates on this please

ads.devel...@gmail.com

unread,
Jul 7, 2015, 12:50:17 PM7/7/15
to adwor...@googlegroups.com
Hello mark, you could post the script to help others who have the same doubts??

Josh Radcliff (AdWords API Team)

unread,
Jul 13, 2015, 9:14:41 AM7/13/15
to adwor...@googlegroups.com, ads.devel...@gmail.com
Hi Amit,

Regarding Java, I don't have a sample program to do this, but the key point to remember is to make sure you are following the recommendations in our thread safety guide for Java. The basic setup would be as follows:
  1. Create a thread pool (ExecutorService)
  2. For each clientCustomerId (AdWords account), create and submit a new Callable to the ExecutorService. This Callable should:
    • Create a new AdWordsSession with the clientCustomerId set properly.
    • Create a new ReportDownloader, passing the AdWordsSession created just for that Callable.
    • Invoke downloadReport on the ReportDownloader and process the results in whichever way fits your use case.
    • This will be very similar to runExample in the DownloadCriteriaReport.java example.
  3. Track the results of each Callable returned by ExecutorService.submit. Resubmit any failed requests, provided they failed because of transient errors (see Anash's earlier post).
  4. Call ExecutorService.html.shutdown() to clean up the thread pool when done.
Cheers,
Josh, AdWords API Team

Reply all
Reply to author
Forward
0 new messages