https://plus.google.com/115280506435026199799/posts/a73o1yCktrX

Well, I thought I would have a nice post about how making the effort to 
switch from AdWords Scripting to directly programming the AdWords API is 
worth it. Now I'm not so sure.

Backgroup: AdWords scripts were doing exactly what I wanted. Easy to get 
data, easy to put it in a spreadsheet. The problem is that I wanted the 
same script in 12 campaigns, and the script needed changing - and it's SLOW 
to change scripts in a lot of MCC accounts. I knew it was time to bite the 
bullet and get into the AdWords API.

To start with, getting a PHP program to run against the API was a few steps 
more than I imagined. I needed to read a lot of documentation before I 
found that you really only need to fill out 4 variables in the file 
\adwords-examples-and-lib-5.1.0\lib\Google\Api\Ads\AdWords\auth.ini file to 
get started.

*developerToken* From the AdWords MCC - “You can sign up for the AdWords 
API when logged in to your MCC account. Navigate to [Settings (gear icon in 
top right corner) > Account Settings (drop-down menu) > AdWords API Center 
(left menu)] and follow the instructions to apply for AdWords API access.”
*client_id* from oauth (AdWords API - PHP Client Library - Migrate to 
OAuth2<http://www.youtube.com/watch?v=KetKPhxY4Js>
 helps)
*client_secret* from oauth (
https://github.com/googleads/googleads-php-lib/wiki/Using-OAuth-2.0 also 
helpful)
*refresh_token* After all the above is filled, run the php script 
adwords-examples-and-lib-5.1.0\examples\AdWords\Auth\GetRefreshToken.php 
and follow the instructions

*First gotchas*
- I put the api folder one level below my apache root dir, which means the 
scripts did not run out of the box.
- Then I found that you shouldn't even be running the php scripts from the 
browser, but rather from the command line (from the api folder). So run 
cmd.exe, cd into the api folder, and run *php {path to script}*commands. 
This actually makes sense from a security point of view, but I imagine it 
was done just because the AdWords API guys are all Macintosh users who live 
in the command line... but that's not ideal for Windows users! ;->

Then I hit a brick wall. I needed to do the equivalent to the below snippet 
(in AdWords Script) in the API
 var report = AdWordsApp.report(
      "SELECT CostPerConversion from ACCOUNT_PERFORMANCE_REPORT during 
YESTERDAY");
    var rows = report.rows();
    while (rows.hasNext()) {
      var row = rows.next();
      Logger.log(row["CostPerConversion"]);
    }

I was first misdirected by reading lot of documentation about old API 
versions. The v201309 version of the API requires you to generate a report, 
download it, and then parse it (your choice of XML, CSV, etc.), before you 
can get the data. Say what?!?!?!

My temporary solution was to move back to the v201306 interface 
(depreciated, but supported through March 31st 2014), loop through the 
campaigns, and use their old "stats" object (where you get to learn fun 
things like what microAmounts are (they are currency times 1,000,000 - very 
useful! grrrr!).

I now have about 10 times more code than all my dozen AdWords scripts 
COMBINED. So far, not impressive. Why can't I just use AWQL and grab the 
data I need?!?!?!

Next I needed to limit by labels (in AdWords Script, it's*var 
campaignIterator = AdWordsApp.campaigns().withCondition("LabelNames 
CONTAINS_ANY ['Brand']").forDateRange(periods[i]).get();*). Here is where I 
started to question if this was all worth it... turn out labels are not 
supported in the API. [rimshot]

You know what I would really wish for by now? The ability to set AdWords 
scripts and grab the results from the API ;->

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to