Yuma 4×4

Media and Communications

AdWords API DevBytes Episode 4: Code Samples and Reporting

AdWords API DevBytes Episode 4: Code Samples and Reporting


[MUSIC PLAYING] XERXES DOTIWALLA: Hi. I’m Xerxes, developer
advocate here at Google, back with the next installment
in our AdWords API series. Let’s take a closer
look at the anatomy of an API call by digging into
the code samples which can make your life a lot easier. Jump into Eclipse and
open up the Java file we used back in episode
two, getcampaigns.java. If you have no idea
what I’m talking about, please go back and
watch the earlier videos in this playlist. In getcampaigns.java, you’ll
notice some boilerplate code in main that does the
following– credential generation, AdWord session
creation, and AdWord services instantiation. You’ll become
familiar with these as you explore the
client libraries. There’s one other line
you may also need. Recall that we set
our client customer ID in the ads.properties file. But what if you have many
client customer accounts under your [? MTC ?] account? In that case, you can remove it
from the ads.properties file, and programmatically set it
via the AdWord session object. After the object is built,
call set client customer ID to dynamically set it. I’ll take this
opportunity to tell you probably the most
important thing to know about the average API. The code samples
are your friends. They provide bite-sized
examples of the most popular API functionality. They are the absolute
best place to start when building your own application. For example, they cover
account management, campaign management, error
handling, optimization, reporting, targeting, and more. The two main buckets of
the API’s functionality are reporting and automation. Let’s dive into reporting now. So we start with our best
friends– the code samples. Go to Eclipse and open
downloadcriteriareport.java. You’ll notice the boilerplate
code mentioned earlier in main. The run example method has the
interesting code in this class. Here we create an object
hierarchy defining the report we want,
then we pass it to an instance of
report downloader. Go ahead and run
downloadcriteriareport.java. The Eclipse console
will print the location of the downloaded file. You’ll notice that the sample
code specifies a report type– in this case,
criteria performance report– and some fields. What other report
types are available and what fields do they contain? Here is a complete
reference document. You can use this
sample code along with that document to download
whatever reports you need. In addition to defining
reports with an object hierarchy like
this, you can also use AWQL, or AdWords
Query Language. This is a SQL like
language that allows you to build reports
in a less verbose way than through objects. Compare the sample code we just
ran with downloadcriteriareport with AWQL.java. They retrieve the same report,
but the AWQL is more concise. The report types and fields are
the same for either approach. So now that you understand
the fundamentals of reporting, you’re equipped to build your
own custom reporting platform. We’ve come a long way in these
videos, and in the next video, we’ll look at how to
make updates to the API, and thus enable some
interesting automation. Thanks for watching, and I hope
to see you in future episodes. [MUSIC PLAYING]

3 thoughts on “AdWords API DevBytes Episode 4: Code Samples and Reporting

Leave comment

Your email address will not be published. Required fields are marked with *.