Getting started guide to the AdSense Management API (v1.4)

Getting started guide to the AdSense Management API (v1.4)


JOSE ALCERRECA: Hi, and
welcome to this new video about the AdSense
Management API. I’m Jose Alcerreca. SERGIO GOMES: And
I’m Sergio Gomes. JOSE ALCERRECA: This
session is meant to be a getting started guide,
so we’ll cover everything from APIs in general to the
new features in version 1.4. So if you’re familiar
with the API, you can jump to the more
advanced topics using the links that you will find in the
description of this video if you’re watching from YouTube. SERGIO GOMES: So we should
start with a little introduction to AdSense. AdSense is Google’s program
for publishers to earn revenue by displaying advertising
on their websites. And the way the AdSense
management API ties in with this is it allows you
access to your AdSense data programmatically. This includes all of your
inventory data, which would be ad units,
ad clients, channels, all of that information, as well
as the ability to run reports on your data and other smaller
features, such as the ability to list your alerts. JOSE ALCERRECA: OK. So what is an API? Let’s see an example. Imagine you want to create
a widget for your smartphone that checks the weather. You’ll need somewhere to
fetch this information from. In this example, we created
this fake weather API by specifying a city
in the query parameter. If we open that with a browser,
we get something like this. A response with
a known structure that we can easily parse. Usually requests and
responses use XML or JSON as container formats. So let’s query a real API now. This is the API Explorer, which
is an awesome tool for learning how to use Google
APIs and also is great for debugging problems. In this case, we are making
our request against the YouTube Data API, and we’re using the
youtube.search.list method. The only parameter that
I have to fill in here is [INAUDIBLE] parameters
[? of ?] part and q, which is the string
that I’m looking for. If I press Execute
here, you can see the request that I’ve just
made and the response, which is a JSON document with all the
results that I’m looking for. SERGIO GOMES: So of course,
what you’ve seen here so far is all raw
requests against the API. Now, you don’t have to
code everything by hand. We actually have
client libraries for a number of different
programming languages that make your job a
lot easier by handling a lot of the boilerplate
stuff such as authentication, discovering services–
since we have so many APIs, we actually built
a Discovery Service that lists all of them–
and also other things such as building the
requests, parsing the responses, et cetera. JOSE ALCERRECA: So
here you can see examples for four
different languages. As you can see, it makes
the requests much easier to use than coding everything
by hand, especially handling things like authentication. The first example
is Java and lists the ad clients of an account. In the second example,
it’s a Python example that gets the ad
units for a client ID. The PHP sample gets the custom
channel supplied to an ad unit. And the last example defines
how you would configure a report in C#. SERGIO GOMES: So some of the
important features– the most important features, actually–
when you’re doing reporting is the ability to have
your own channels. And these channels
come in two types– custom channels
and URL channels. The first, custom channels,
are defined by you, and you can assign an ad unit or
multiple ad units to a channel. And so this allows you
to give specific meanings to sets of ad units. You could have, for example,
a set for all of the ad units that display on the top
versus all of the ad units that display on the left. Or you could assign different
meanings such as categories of the pages that you’re
displaying these on. In terms of the
URL channels, these are actually filled
in automatically, depending on the URL of the page
that the ads are displayed on. So in terms of authentication
and authorization, the API uses the
OAuth2 standard. And we support two different
types of application– web application, which handles
all of the applications both from server side and
client side perspective, and installed
applications, which can go from anything from a
full GUI desktop application to just a simple Python script
that runs in a cron job. The AdSense Management API does
not support service accounts because service accounts
do not allow access to protected user data,
which AdSense data is. In terms of reports, you
have the full flexibility of the AdSense
reports at your hand. So you can run the
exact same reports that you would run on
the AdSense website. This includes running a report
for one or multiple ad clients. Same thing for ad units,
channels, et cetera. You can configure
these any way you want. You can add filters, et cetera. JOSE ALCERRECA: So if you
need to fetch a report, you should check out the list
of dimensions and metrics available in
developers.google.com. Now let’s see an example
using the APIs Explorer. In this case, I’ve pre-filled
the date range, the dimension, which is date. I added two metrics,
as you can see here, and now I can’t really execute. I have to authorize first. So for that, I use this
button here, click Authorize, and we’re good to go. SERGIO GOMES: That’s actually
the OAuth2 [INAUDIBLE]. JOSE ALCERRECA: It’s
generated my request, and here I have the response
in a JSON file or object. SERGIO GOMES: So
in version 1.2, we introduced a couple of
new features– Ad Styles and Saved Reports. The first one allows you to get
all of the styling information for an ad unit, which means
colors, fonts, corners, whether they’re rounded or
not and how rounded they are. And the second
one, Saved Reports, allows you to run your
existing reports, which are configured in the
AdSense website via the API, and handle the results
programmatically. In v1.3, we added a few
new features as well. We added the ability to list
your existing account alerts. We added metadata to reporting,
which gives you the ability to list your
dimensions and metrics, the dimensions and metrics that
are available to your reports, as well as the
relationships between them, which ones you can use,
which ones you can combine, and which ones you can’t. And we also added the ability
to generate ad code for existing ad units so you can get
the JavaScript snippets and insert them
into your website. JOSE ALCERRECA:
In version 1.4, we added a code to list
your payments, which was a highly requested feature. Also, now you can
delete alerts, which is the same thing as dismissing
them in the AdSense web interface. And finally, we added two fields
to the report response– start date and end date. Especially important if
you’re using relative dates like yesterday,
start of month, today minus one month, et cetera. If you want, you can
check the reporting guides to learn about this feature
in developers.google.com. SERGIO GOMES: So thank you
for watching this video. And speaking of
developers.google.com, you can find all of
our documentation at
developers.google.com/adsense. You can follow our blog at
googleadsdeveloper.blogspot.com, and you can follow
our Google+ page, which I’m not
going to spell out, but the URL is in the slide. You can see. JOSE ALCERRECA: OK. Thank you. SERGIO GOMES: Thank
you for watching.

Daniel Ostrander

Related Posts

1 thought on “Getting started guide to the AdSense Management API (v1.4)

  1. oscar chambers says:

    Thanks for this video but it really doesn't help at all

Leave a Reply

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