Mark Hamill | Mark YAML

I have my googleads.yaml file – now what

It’s a beautiful file containing everything you need to connect to the Google Ads API, well almost everything. You’ll need a computer, client library, adwords account and half an interest in making API calls to Google Ads – or a manager who’s telling you you have half an interest in making calls to it.

It’s good to start out by just saving the googleads.yaml file in the root of the project folder you’re working in as the client library will automatically look for it there, however in production you’ll most likely want to load the credentials from environment variables.
If you are reading straight from the file ensure you add it to the gitignore as you don’t want to be pushing it up to a public repository!

Here’s an overview of how to make your first API call, it’s OK but for total noobs it can leave a few questions unanswered.

First off you’ll need the ID of the main account you want to extract the data from, when you first start out it’s a little confusing having customer, client, customer_client, client_customer… however just get the main client account you want to read from and later on you’ll get all the customers under that

Resources & Services

There are two key things you need to know about the Google Ads API – Resources and Services.
Think of resources as API endpoints – when you call that resource you supply the resource name and a unique identifier, so if you were calling the Customer endpoint (the main client account in our example, lets say 123456789) your endpoint would be:

customers/123456789

and from this endpoint we’d be able to extract all the data we need for that customer.

If we then wanted a specific campaign under that account we’d need to reference the customer endpoint, the account (OK customer) id, the campaign endpoint and then the campaign id (assume 987654321) we want to retrieve the data for, it’ll end up looking something like this:

customer/123456789/campaigns/987654321

Now this is all fine until you start translating that through the client libraries, prepare to open up a can of worms.
We’ll come back to resources when we work through some examples however the other key topic is services.

So services are things you use to modify resources, and while there are a plethora of Resources; fortunately we only have to remember 3 services – and they’re pretty easy depending on what you want to modify.

  • CustomerService – used to modify Customers
  • CampaignService – used to modify Campaigns
  • AdGroupService- yes you guessed it, used to modify Ad Groups!

The final piece in the puzzle is the ability to to retrieve objects and performance data – you do this by using the GoogleAdsService. When using the GoogleAdsService you pass in a query that references the resource you’re looking to query along with the attributes and performance metrics.
You can break down the data even further using filters. There’s a Query Language Guide however when first starting out I found the Query Language Builder a great tool to get up and running quickly.

Because we’re accessing our own Google Ads Account and not building an application that needs to request access to others we can skip over Oath for the now… we may revisit later if I remember.

Next up we’ll run a query to get the accounts under a manager account

https://memegenerator.net/img/instances/55489985/omg-too-many-versions.jpg

The every changing Google Ads API

Where do I start with this one… I’ve seen v1 come and go, v2 come and on the not to distant future it too will be saying goodbye and heading up to the little computer in the sky.
Version 3 was in beta, then it was in production, then it was back in beta… that’s fine as it worked and v1 code was ported to v2 and being redied for v3… then it paused. But wait, then we had v4 (beta), but v3 is still in beta right … but wait now we have v5 (beta) – confused, I definitely am!

I’m using v3 here because, well for no other reason as if I try and make API calls to v4 in Python you get an API version error response saying I must use v3. I haven’t tried upgrading to v5 yet, I’m waiting for v6 to come out 🙂

The shift from v2 to v3+ seemed to move more towards GraphQL and what on the face of it looks like SQL, with the familiar

SELECT this FROM that LIMIT 10; 

While not true SQL it’s as near as darn it for anyone from a non technical background looking at it. So we’ll start here with some basic reports and data pulls and let’s see how it goes.

I’m only hAPI when it rains…

When I first started building web applicaitons I remember looking at an API and thinking ‘this is freaking amazing!’, all I was doing was showing the journey between 2 locations using TFLs API.
Fast forward to today and I’m now navigating the tech platforms APIs, namely Google, Facebook, Twitter etc. – and there are things which aren’t that obvious, and if I haven’t used for a while have to refresh how to do.

I’ll try to walk through some of the common things I do day to day with APIs, partly for reference material to go back to, partly so other people can do the same, and partly because the API versions are an ever shifting and it’s a job to keep on top of them!

I’ll save generating an token, secret etc. for another day, or for someone else as there’s a myriad of tutorials out there which cover this… I’ll leave that to the experts 🙂

I’ll be mainly using Python to work with the APIs, I may show the same in Ruby if they have a library and later down the line I may even build an application out in either JavaScript or Rails… depends how much time I have as I still have a day job.

Anyways, hopefully someone out there in the void finds this useful