Yuma 4×4

Media and Communications

AdWords API DevBytes Episode 5: Automation

AdWords API DevBytes Episode 5: Automation

Xerxes a developer advocate here at Google, back again, in
our Adwords API series. In this episode
we’ll examine how you can use the
API to make updates to your AdWords accounts. We’ll look at a few
popular use cases, and see how they serve
as a basis for almost any kind of automation. One of the most common
use cases of the API is to pause and
resume ad groups. For example you
could pause an Ad when the inventory
for that item is depleted, resulting in better
use of your advertising budget. This highlights the power of
integrating your own systems with the AdWords API. So how would you actually
pause and resume an ad group? Remember from the last video? The code samples
are your friends. You should have them
downloaded by now. But if you don’t, you
can grab them from here. Again we’ll be using
Java and Eclipse, but the concepts are the
same for all the client library languages. Fire up Eclipse and
open updateadgroup.java. We see our typical
boilerplate in main. This time you’ll notice that
main has a placeholder string for the ID of the ad group. Where would we get that ID ? Well you could get
a programmatically through the Get Method of the
ad group service interface. One unofficial trick
that I use for testing is to grab the ID from the URL
of the AdWords web interface when viewing an ad group. As usual the Run Example
method as the interesting code. First it gets a reference to
the ad group service interface, because it’ll be making
an update to an ad group. To update other
entities you would use of their corresponding service. A full list of available
services can be found here. Then it creates a
new ad group object. It sets the ID of the new
object to the ID of the ad group that it wants to update. Then it sets the
status to paused. After that, it creates
an ad group operation using our newly created ad
group object as the operand and set as the operator. Lastly, it calls the mutate
method of the ad group service interface passing in the
ad group Operation Object. So go ahead and replace the
placeholder with an ad group ID from your test client account,
and try running the code. After it runs log into the test
account and the web interface and confirm the status
has been changed. This same pattern is used for
most updates through the API. So let’s review it here. Create a new object. Set it’s ID to be the ID of
the entity you want to modify. Set the new value of the
property on that new object. Create an Operation
Object with set as the operator and this new
entity object as the operand. And lastly, pass
the Operation Object into the mutate method of
the appropriate service. This is an update, so
we use the set operator. Adds or removals would use
the Add or Remove operators. If this seems
confusing, take a look at other pieces of sample
code in this project. You’ll quickly see the pattern. So now we know this
pattern, we can easily make other updates as well. Though many require more complex
objects than the ad group status enum we used here. For example another
popular use case is to modify the bid for an
ad group programmatically. The canonical example
is raising the bid for an umbrella add
when it’s raining. Your app could consume
a weather web service and then use the
average API to increase the bid for this ad group. You could modify this same
update ad group sample code to make that kind of update. Instead of setting
the ad group status, you would set the
bidding strategy. Click this link for details
on how to configure a bidding strategy. Another use case is
creating new campaigns. In Eclipse take a look
at adcampaigns.java. It’s quite a bit of
code, but it follows the pattern we just discussed. In this case, once the
object hierarchy is created, we use the add operator to add
a new budget via the budget service and new campaigns
via the campaign service. We don’t need to
set the ID’s here because these are new entities
and don’t have ID’s yet. So those are just a few examples
of updates using the API. I said it before, and
I’ll say it again, I highly recommend you go
through the code samples as they really are the
best way to learn this API. We have accomplished a lot
in these last five videos. You made your first API
call, retrieved reports, and got a taste of automation. Of course, there’s additional
API functionality to learn. These guides will definitely
help you along the way. Now you’re ready to start
building your own real AdWords API application. And once it’s up
and running, you’ll see increased
operating efficiency through automation
and greater visibility through custom report. Thanks so much for being with
us through these initial steps. And keep an eye out
for more AdWords API videos on the Google
Developers channel. [MUSIC PLAYING]

4 thoughts on “AdWords API DevBytes Episode 5: Automation

  1. Xerxes, thank you. Great explanation in the series, simple and concise. Thank you. One question though, Xerxes as the "Xerces" xml API? I know you heard that before 🙂 . Congrats!

  2. hello, I want to get a campaign with all its ads and keywords to be displayed. where can I find an example? thank you

Leave comment

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