AdWords API problems
I finally started using the Google AdWords API this week. Generally, this allows you to do anything you do by logging on to the Adwords site programmatically. However, it seems there are some things you can only do through the UI at the moment and even a few things you can more easily do through the API.
The service is in Beta at the moment (like most Google services!) and as such has limited support. Basically, there are references and lots of help docs, some sample code and a developer’s forum which is not exactly buzzing. The documentation is easy enough to follow and there is a fair amount of it. However, I found that it may not be complete.
I am only using the API with C# in very straightforward ways to gather reports, but I have already come across 2 occasions where following the instructions has not worked.
The first thing I had trouble with was setting the aggregationType for my reports. Although I was specifying:
myReportJob.aggregationType = AggregationType.Daily;
I found that I was stuck with the Summary view!
I only found the solution by chance when I saw a line of code I was missing in a post on the developer’s forum:
myReportJob.aggregationTypeSpecified = true;
I still cannot find this line mentioned in the documentation and it seems weird to me that you need it. Surely you are specifying the aggregation type by setting a value for it?!
I am still looking for a solution for my second problem. To use the AdWords API, you need to have a My Client Center (MCC) account. The idea is that the MCC account links all your AdWords accounts together in a central place. They all still exist separately, but the MCC provides a parent level of access where you can drill down to each account but also perform operations on multiple accounts together. This is useful for search marketing companies who manage AdWords campaigns for multiple clients.
Google recently added reporting functionality to the MCC, so that it is now possible to create just one report in the MCC that includes data for all accounts. Since API usage is limited to a certain quota of operations each month, depending on how many accounts you have and how much you spend, this feature is great. It means that you can just run one report instead of one for each account which is far more efficient. Except I cannot get this to work!
Update: I have seen reports on the developer forum that if you add a line ReportJob.crossClientSpecified = true, then generating a report at MCC level will work.
The relevant Adwords documentation states the following:
If you have registered with My Client Center (MCC) to administer
accounts on behalf of your clients, you can get reports about your
clients’ AdWords accounts. To do this, login without setting the
clientEmail header. When setting up the report job, you need to set the crossClient and clientAccounts fields. Set crossClient to true, and specify a list of the Ids of the accounts to include in the report as the value of the clientAccounts field.If you set the crossClient field to true and do not supply a value for clientAccounts, the generated reports include all the client accounts
These instructions seemed simple enough, but when I use the following C# code while specifying the MCC account login details, all I get is empty report columns with zero totals:
//#instantiate Report service
ReportService service = new ReportService();
String myUseragent = “SMCM: Get report for all campaigns”;
String myEmail = “***[MCC Account Email]***”;
String myPassword = “***[MCC Account Password]***”;
String myToken = “***[MCC Account Token]***”;
DateTime myStartDate = new DateTime(2005,7,21,12,0,0);
DateTime myEndDate = myStartDate.AddDays(4);
String myReportName = “test”;
//#set service properties
service.useragentValue = new useragent();
service.useragentValue.Text = new String[] { myUseragent };
service.emailValue = new email();
service.emailValue.Text = new String[] { myEmail };
service.passwordValue = new password();
service.passwordValue.Text = new String[] { myPassword };
service.tokenValue = new token();
service.tokenValue.Text = new String[] { myToken };
//#create report job
KeywordReportJob myReportJob = new KeywordReportJob();
//#set report job parameters
//#set crossClient to true to access individual a/cs from MCC a/c
myReportJob.crossClient = true;
//#don’t set clientAccounts so that all individual a/cs will be
included
//#don’t set campaigns so that all campaigns will be included
//#don’t set keywordStatuses or keywordType so that all will be
included
myReportJob.aggregationType = AggregationType.Daily;
myReportJob.startDate = myStartDate;
myReportJob.endDate = myEndDate;
myReportJob.name = myReportName;
If I specify login details for an individual account instead, I get a complete report which suggests that my code must be OK in the main. Maybe I have missed something in the docs or perhaps there is another magic line of code I’m missing. At the moment, I have to run a report for each account so if you know where I am going wrong, please enlighten me!
A final niggle I have found is that even though I just want to replicate running a Keyword report, I have to run a Custom report to get the info I need. This is because even though you can check a box on the UI to include conversions for a Keyword report, the same option cannot be set in the API, unless the docs forgot to mention that as well. This is a minor gripe, but Custom reports are slightly longer and messier to code as you have to specify all the columns you want etc. It would be nice if the API mirrored the UI. Perhaps when (if?) the service comes out of Beta the 2 will be perfectly in sync.
Overall, it is fantastic that Google have made an API for AdWords freely available and are continually improving and extending its functionality. It is just frustrating when you run into issues and the chances of resolving these quickly is drastically low due to the lack of real time support.



July 30th, 2005 at 12:38 pm
I played with some of the PHP and Perl example code a couple of months ago and it seemed to work fine. I haven’t found any practical use for it yet though
July 30th, 2005 at 12:51 pm
yep the examples worked for me too michele, as did most other quick things i tried out…
but in accordance with murphy’s law it’s the couple of things i really need to do that i have trouble getting fully up and running!
July 30th, 2005 at 2:50 pm
I haven’t tried the APIs for Adwords yet but they seem interesting. By the looks of it there could be minor niggles though. C# looks fairly easy to use. Must see if I can learn it.
November 29th, 2005 at 6:30 pm
You need to add:
myReportJob.aggregationTypeSpecified = true;
This will solve it
November 29th, 2005 at 8:48 pm
*many* thanks mark - i will give that a try - they did not mention that in the docs when i looked into them at the time though?
if you are setting a value for the aggregationType parameter it’s kinda obvious that an aggregation type is specified but whatever google wants
thanks again!
March 26th, 2006 at 11:54 am
I have seen reports on the developer forum that if you add a line ReportJob.crossClientSpecified = true, then generating a report at MCC level will work!
September 10th, 2007 at 10:56 pm
Awesome. I was having the exact same issues, but I added the two properties and all is good. Thanks
August 10th, 2008 at 2:02 pm
Hi Janine, same problem I was having, I slotted in crossClientSpecified and it worked fine. Your post helped me solved this. Going to post over at Google API group to request an update to the documentation.
August 10th, 2008 at 10:08 pm
Good to hear from you Dave and nice to see you back blogging again too. I’m amazed that this is still an issue with the API 3 YEARS ON!! I haven’t touched any of the PPC APIs in about 2 years - I’m sure the AdWords one has changed an awful lot since…