All The Little Steps To Get Started With The Google Ads API

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this video is going to show you how to authenticate with the google ads api and you're going to be able to make your first api call without even needing a real life account there's a ton of just little steps that google forces you to take mostly related to authorization i'm gonna walk you through how to do all of them it really is very simple but there's a lot of little buttons to push which is why i made this video by the end of this video you're gonna have four different codes you're gonna have your developer access token which is basically the code google assigns to an mcc it's like the google ads specific authorization code you're gonna have two oauth credentials anytime you integrate and you say like you act on behalf of a google user like you're saying uh i want to create an ad group in this campaign on behalf of this person you know you need to go through the google oauth system i'm going to explain that in more detail and finally you're going to have the refresh token if you've ever granted access to an application that said hey you know this app wants access to your google calendar like calendly that actually gives them something called a refresh token it allows them to make changes on your behalf so i'm going to show you how to get that for any user and last thing this is going to be a pretty short video this is going to take you just from zero to one if you're looking to build a full-scale application that manages user credentials and you know lets people make changes to the google ads api automatically this will get you started in the right direction but ultimately you're going to have to take a few extra steps and i will include some resources for you in the description all right to get started we're gonna start with the developer token i promise this is the most challenging token to get it's super annoying you have a bunch of little hoops but at the end of the day you just gotta get it done um so you do actually need an mcc this is a google manager account i'm gonna include how to create one in the description um so if you don't have one yet you know please go ahead and do that uh and again this is basically google's way of identifying you know who made the uh api call oh it was austin's mcc or your mcc this page this is the page that i'm following i'm just gonna walk through it and show you all the places to go in this step tool it tells us to go to tools and settings setup and api center um go ahead and fill out these this form it's really simple don't over think it uh after this you're going to be given a test token i'm going to talk about more what this test token actually does in a second but if you're planning to use this on live accounts what you're going to want to do is click the apply for basic access and you're going to get taken to this most beautiful form from 2004 and after you fill this out you're going to actually be able to operate on live accounts to continue with this tutorial you actually don't need to wait you can uh create a test account under a test mcc it'll take you like five minutes uh again in the description i'm gonna have a link to how to get that done all right developer token is done that i promise was the hardest one the most form fields and if you're thinking that was pretty easy i got some good news for you because the rest are going to be even easier back down to oauth credentials you're going to have a secret and a key or something like that i actually can't remember what they're called following the documentation that google lays out we basically need to create a google cloud project and within that project we need to do a couple of things so i'm going to walk you through that right now all right so you can see i already have projects but i went ahead and clicked the create new project name the project whatever you want and then you're going to be taken to this dashboard once you're in here it'll take a second for the project to actually be created once it has been make sure you select that project go to the search bar search google ads api and then just click enable all right next step we're going to create the oauth consent screen that's something that looks like this uh basically we ask people hey can we get credentials to act on your behalf and for your reference i'm going to follow the guide that google lays out right here so within your google cloud project go ahead and search for credentials and click on this second one with api create credentials oauth client id and configure consent screen click external this basically means you're going to allow anybody to use it if you're only letting people with the same domain uh as a domain that is registered with your google cloud project like a company domain use it then go ahead just click internal and then you really can put whatever app information if you're only planning on using this internally you know this really doesn't matter uh if you want to verify it for anybody to use it without getting like this weird warning screen you know that's when you're gonna want to uh you know have an application home page a privacy policy etc etc we're going to ask them for access to the google ads api so within this scopes section type in google ads api select it and update save and continue save and continue again and back to dashboard now with our consent screen created we're going to go ahead and create credentials i usually set web application uh this is just the simplest way to do it of course if you're making a desktop application you can change that later for the authorized javascript origins the client that is used by you like the python library the php library actually needs to have your localhost enabled so we're just going to copy in this localhost ip address and then finally you get your credentials go ahead and copy and paste these somewhere safe one last little step all we need to do is click this push to production the publish app confirm and there we have it this is live this can ask users for their credentials and actually get what's called a refresh token that we can use to interface with google ads on behalf of users last thing just to say one more time this will work perfectly for up to 100 users but you do have some limitations if your app isn't verified every time you ask for someone's refresh token in this example we're just going to be getting our own you'll be presented with this ugly google hasn't verified this app are you really sure you want to give them access to everything you can do on google ads screen that's okay just in the future if you want to avoid that it's a really simple and free process to actually verify your app all right three out of your four tokens are down we have the google ads developer token we have your oauth credentials and finally we need the last thing which is the refresh token for the user again this basically says we have the authority to make changes to google ads as someone else now this this should go without saying if you get these tokens please don't just commit them to github or email them around because literally anything you can do with google ads including spending tons of money can be done with this set of credentials and worst of all if it get gets leaked it'll look like it was you who did it so please exercise caution this refresh token there's two types of tokens when interacting with google ads there's an access token and there's a refresh token if you're using a library specifically made for google ads developed and published by google you don't need to worry about the access token you only need to put in the refresh token and again if your app is not verified this refresh token is good for a full seven days so this is pretty simple to do um i'm gonna walk you through something called the oauth playground where it's basically your google's friendly tool for developers to generate refresh tokens i'm also gonna have this page in the description and the oauth playground link it's really handy because it's pre-populated you can see here what you need to do is put in your oauth client id and oauth client secret and once you have them copy and pasted go ahead and click authorize apis you're gonna choose who you're gonna log in as continue and then finally again hit continue you will be presented with this screen which says something about a 302 not found just click the big blue button and you will be presented with your refresh token again please keep this in a safe place i hope you're ready to start writing some code because we have everything we need and i'm going to show you how to make your first api call and i'm going to introduce you to a free repository that i have some examples in everything's already set up for you all you need to do is plug in your credentials at this github repo which is public publicly licensable code you can go use this for whatever commercial personal projects you want i'm going to start with the boring thing which is this dot end file this does not get committed to github this has your developer token refresh token client id and client secret i also put your account id and your mcc id and i'm going to show you why i have both of those in here again your account id is the account you're currently working on that's the google ads if you try to add it like to your mcc or get access that's the code you ask for from customers and the mcc id is just the id of your manager account if you have one if you're just directly attached to an account you don't need to do this but if you only have access to this google ads account via an mcc you actually do need to put this in here so i am going to walk you through how to make a google ads client this is basically an authorized client that then can perform actions like querying for data creating ad groups creating ads etc etc so this function i have in the make client package accepts an mcc id and is which defaults to an empty string so again uh if you actually do want to operate via an mcc um you do need to attach it to the google ads client like i show here this is all very simple it's just a google ads client we load the credentials from a dictionary after getting the config from our environment file and then we return a google ads client if you want to test this out right now go ahead and just click this play button and it ran without errors so we are good one thing that i have found to be really helpful on all my accounts is analyzing search terms you know you can do really fancy things like engram analysis build negative keyword lists so the query that i'm going to show you guys is how to query every single search term that has ever come through your account which you can then use to analyze the data so again if you're not that familiar with python i do have this if name equals main which just allows you to run the file from the file without calling it so i am going to walk you through it so the arguments we have are the account id the mcc id and the file name so this is actually going to output your results into a csv if you want to load that into a data science library i find it's just handy to have it in a dead simple file format but the only thing that you actually need to pass through is this account id so let's walk through it uh up top i create this full file name just to you know just a python utility class to create where we're actually going to save the file so make sure it's cross-platform so after we have the file name again if you don't pass anything through it's just going to default to search terms as you're working on multiple accounts it might be useful to not override your past query we're going to make this client and then we're going to make the google ads service client which just is where we can execute these functions from here i have a query as a little bonus i'm going to walk through the query builder with google ads so you can actually build your own queries and get anything you want really really simply um we're going to create a search request and we're going to stream this so it's actually a more efficient way to get data we're going to set the account id and we are going to create the query finally i open this file name the results page and create a way just to write to the csv again i apologize if you're already really familiar with python and i'm going over really basic stuff i start by writing the header row which really is just again it's this search term cost etc and then i iterate through the stream so google ads api is actually built with grpc and protobufs which is a lot less friendly than something like json so if you do debug it it's going to be a little bit more challenging so i actually destructure things to get the fields that i want so you see this metrics equals rows.metrics the reason i know the name of the field i am accessing is because uh the query actually has like metrics.ctr metrics.clicks so i know the metrics is going to be row.metrics and it's actually going to be named the exact same thing from the query and then finally we're just going to write each row to the csv so i'm going to show you what that looks like i'm going to click this nice little play button it's going to run for a few seconds this account has about a million in spend and within this query cache i have my csv file with my search terms campaign name costs uh it's it's in micros so you're gonna have to do some currency conversion to get it actually into the uh the correct decimal as mentioned here is the google ads api query builder so if you're looking to build any query to get data from google ads it's broken down into different types of views so on the left we have every single different type of view that you can pull from i'm at the keyboard view but there's also landing page view really anything that you can think of that you could do within the google ads ui you can do from here so i click to select my average cpc you know the keyword text as well as a campaign name from my keyword view all i need to do is copy and paste this into uh my query change the fields that i access and there we have it it should print out nicely to a csv so youtube in this video i showed you how to get all the necessary access tokens for your google ads api we had special guest appearances from fidel who is now sitting over there and this is zodie who doesn't like being held i hope you find this useful again this is just the nuts and bolts nitty gritty super boring stuff to getting your google ads api integration working there's so much you can do if you enjoyed it you know please leave a comment about what you want to see up next
Info
Channel: Build With Austin
Views: 30,031
Rating: undefined out of 5
Keywords:
Id: HXKpfGqPRy0
Channel Id: undefined
Length: 17min 23sec (1043 seconds)
Published: Wed Apr 13 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.