Google Ads Automation with Python - How to Build Reports in API and Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everybody my name is roman and it's marketing watch house and welcome back on google ads plus python tutorial and this is the third series when we go and try to do something something interesting and smart there so we already built our the setup which contains the developer key the access token and all this stuff and there is also a test code that you can just run and have a look and by the way for those who didn't know that one it does not change anything it just downloads the report and i also had people asking me in the comments like uh what do you think is going to be like the most like common thing to use it for what should i shoot for should i go for bidding and my answer would be not exactly unless you like absolutely sure what you're doing i would say bidding is not the most interesting or smart thing to do with google ads python script first of all because bidding usually is done on a higher level and it only needed for a very specific amount of keywords and it can be basically done in google ad scripts which does not require you to do a lot of deployment and stuff second of all there is a t-rose and tcpa which kind of covers most of the cases but the api one allows you to do the reporting on a much bigger level it allows you to create new instances new keywords new ads creates your cross negatives new campaigns changing settings a lot of stuff that is much simpler to do in in python than it's do in google ad scripts and before we go to that interesting stuff what we need to do first is to go through the code that we already know uh and we already tried and try to understand what it consists of and the most interesting stuff about it is how to change it to make it work for you so today we're going to talk about the reporting how to make the reports in a with a google ads api so this is the code from my last usage which is called google download keywords from account and this one is from examples it just downloads keywords to your account just a small reminder that we have the main function uh that have a client that is coming through our init file and it gets serviced google ad service with version 5 and then the interesting stuff happens so to get the reports from google ads there are a lot of different ways to do that and in majority of the cases of course you might want to use the bigquery but in this case we directly query stuff from google ads and the benefit of it is that it's free you don't actually have to pay for it it doesn't matter how big your account is or how much you download unless of course you hit the limit which is unlikely to happen but the thing that is here it's not sql it is kind of sql it's sql-based language that is called uh google ads query language or goggle and this is the updated version of query language it used to be awql and if you do automation with google ads scripts or you've seen my videos about google ad scripts that actually the google ad scripts is using awql sorry it use kl which is a previous version and even i get confused but this is important stuff guys is that you should not be confused which one you need to use for api we use guckel and it's kind of like interesting stuff if you go there into internet and google for goggle generator you're gonna have a website that will generate for you query you don't need to learn anything it just basically will do everything for you the only thing you need to remember that if you have if you have ad block enabled you might not be able to access this page and it will return you 503 error or something like this so this is the query language and this allow us to generate the query what we wanted to get we will come back to this later so let's look at the code we create some query and this is a sql based stuff so first of all we define what we want to get in select and it's going to be campaign id campaign name and as you can see it has dots in it so there are instances of something like there is a campaign and it has parameters for example campaign have settings name bidding budgeting and all that kind of stuff there is ad group stuff and and group also have some parameters like id and name and also have for example tracking template there is um ad group criterion which is in our case is going to be the keyword but not necessarily the keyword because you might have retargeting remarketing audiences and all that kind of stuff and there are metrics metrics are things like impressions clicks clicks or anything like this and of course to make the gaku work like for work for you in a beneficial way you need kind of to learn a bit of which one of which but at the beginning you can just simply use the website i showed then you decide then you define from where the data is coming to your website for example from keyword view or from campaign view or from wherever else then there are filtering and this is defined whether you want to look at the campaigns that have enough cost or if they have enough clicks or uh what period of time you're looking at do you wanna last seven days or do you have some specific time frames you wanted to query and uh basically this is one of the most important stuff here and the last two things as in classic sql is order by if you wanted the ordered query which is not necessarily true because you can just load it into pandas and the limit and the limit will define how much stuff you will get from account and this is for example one of the popular questions how to make this script work for more than 50 keywords all you need to do is just to get rid of this line or make this line way bigger of course i'm not going to tell you exactly what's the limitation you can read it only in the internet but for majority of the accounts uh you you will not hit the limit anyway then what we do we take this query which contains all the information in the formal way of what we want to get from google ads and we push it to the ga service search stream so there are several things of this there is a search search stream and search batch and there are different ways of getting data from google ads i would say i'm not a developer and i don't care actually i know that search stream works for me for those of you who actually develop stuff you need to go there and look which one serves you better but in general for me for those that do not do this all the time as a main work uh just pick search stream this is the most efficient one it will download any size of the query in general uh in a continuous flow to your to your computer then um this one is not important for the for the moment but what the data actually uh contains it helps us to work with the match types and at this point of time like at this point of time the query the result is already on your computer so we downloaded everything we need on your computer which actually happens like here which is amazing because compared to a majority of other cases uh you don't really need to to handle anything it's just it's already there so the only thing we need to is to get what came to us from google and to some kind of work with it so what we have here we have try uh for batch in response and four row in the batch so the reason uh response is a huge package like a dhl coming from amazon and inside it there are several batches smaller packages but still they're packed and then we take this pack out of the big box and inside this pack there is a there is a row of results so each row represents whatever is the granularity and in that case we working for keyword view so it's going to be each row is its separate keyword so it might sound confusing but when you look at the data it actually like exactly like downloading excel but because you might download like a million keyword size account it not always can come with one single amazon package it's imagine you'd like ordering 50 different things from amazon so it will come in different batches inside different batches will be a lot of different rows this is why we have four batch in response four row in batch results and each row as in excel represents something for uh it represents some parameters so uh what's interesting about the google ads library in python is that you can address the data inside the row exactly the same way as you address it in in here what i mean is for example this is a campaign name and if i want to get campaign name all i need to say is campaign name equals row dot campaign name and if i want to for example get ad group criterion criterion id i can say that id equals sorry row dot ad group criterion dot criterion id so you don't need to learn what these parameters are and you will not be able to just like look at the possibilities you just need to copy whatever you have here and use it there so in this example in this example that we take from the official library what we see here what's happening first the author creates the campaign variable and it says says saves everything of campaign that we know to the campaign variable and later on in the code it uses campaign.name and campaign.id and this is also another way of doing this because if you say campaign equals row.campaign that means that now we can just say for example campaign name print campaign name and it will work so all of this is actually unnecessary it's just to show you how you can take data from the row variable but i think it's pretty nice and self-explanatory this is the case when we need to decompose and take the data about the keyword match type so what's happening there when you get to your amazon package and it contains all the stuff in it not every single stuff there is handled in a way that it's going to be used so some of the stuff comes with the different parts and you need to bring these parts together to make it work for example stickers can be separated or the charger is not complete and this is what happens here so we get some weird stuff for the match types and we need to convert it to things like exact phrase or broad something that we as humans can understand instead of one two three what it actually comes in so this is why we use the enum type to convert it the cool thing you don't need really need to think about it it's just this is a rare case of something like this happening it's always important possible to find the uh stuff in the internet and we'll cover this but even like if it's not the case you can just basically learn what this one two or three means and then they just print it and this is literally the whole code which majority of this code is printing and the report sql query the actual handling with api is happening here sorry here we create the j service we load our credentials then we ask for the response and then we just print the result like this is how easy it is when you know what to do but of course the trick is that you need to know what to do which is difficult so here another one is exception so this is the something that they created the the people that created this library is to show you that sometimes the data that comes to you to you is not correct and it can contain errors and this error have a special type which is google ads exemption and in most of the cases it should not be the problem so it only should be the problem when the internet connection is dropped or some of the data that you requested just doesn't exist or you don't have an access to this data but unless you hit that and if you hit this you will have the the error and it will show you what's happening and the the program will stop for example if you request the wrong id that you don't have an access to but unless you you do this specifically you will not use this code so everything is going to just work and that's all that's that's that's how it is how easy it is so uh let me show you how to work with goggle as i promised to you so interactive google ads query builder builder i will put the link below but if you just need to to look for it it's gaql generator and this is going to be the first link again don't forget to disable the ad blocker so first of all you need to define when you re when you request report from google ads you need to be absolutely sure what you're requesting and this is usually when 95 of problems happening when i work with people and explain this to them i realize that people want to get report but they have no idea what this report should contain it's like is it going to be like campaign information account information or maybe keyword information so first of all you need to think of what this is going to be about and for example i want to go for campaign level information then it's going to be campaign then you can take a lot of fields about the campaign which contains first build strategy bidding strategy sorry then the campaign stuff for example uh campaign ad serving optimization status which is a setting but it also have for example campaign.name which i just need to find so for example campaign id let's just save it for now and can i type no i cannot so campaign.name here it is you also can get the campaign labels if you want let's get them as well here it is and a lot of other parameters that exist on the campaign level for example campaign tracking template you also can get let's just find it it's going to be tracking it is target impression share location uh tracking url template there are some parameters there that you will not directly understand because they don't exist in the same way the existing inter interface so do not try to like add all the information you can get if you don't know how you're going to use it it's just useless if you create the script that will specifically give you the data about whether you have tracking templates in the campaign level or not then just request this information because that will reduce your learning gap a lot and you will not be a you will not have to you would not have to go through all the stuff each time and like feeling frustrated because you don't feel where you need to start and stop so then you need to define the filters you're going to work with oh by the way let's add some metrics so if you go down there is going to be metrics and it's going to be for example clicks let's just stop here add impressions always add impressions here it is so our campaign is going to contain campaign id campaign name and you can by the way get the date of it oh no please don't tell me that i cancelled some fill filters campaign id yeah i cancelled campaign id okay the interface here is not always the best it is so i'm gonna i'm gonna have campaign name campaign url tracking template campaign id and i'm gonna have clicks and impressions for this then the second thing you need to do is to define for which period of time in which cases you want to work with for example i can say that campaign a name should contain something and that would be campaign name like and then i can say for example search or i don't know whatever bmw something like this but i don't i just want to get all the campaigns that have any clicks so what i'm gonna go i'm gonna go for metrics and i'm gonna say uh let's say impressions let's find this um metrics search clicks click-through rate clicks let's just click more than one click and the second thing i need to say is when and when is not a metric when is actually a dimension that is on the very bottom and it contains segment date and date is more than let's just say no no not between but during last month and you also can say if you want to sort your query i don't really want to sort and then we're going to have a limit size so it's not necessarily to have one but the thing is here's my query and if all i need to do is just copy this paste it here and that's going to be enough so this will get me the data on my laptop and it's not going to work perfectly because i need to handle the result and to show it in some way and it does not contain the same metrics as it used to be but i will show you how to do it in the next video subscribe to this channel leave your comments below ask me questions and if you need any support uh you can reach me on linkedin you can reach me in the private ddm or on my email or wherever you can find me and thanks thanks for watching [Music] you
Info
Channel: Marketing Watch House
Views: 6,181
Rating: undefined out of 5
Keywords: google ads api, google adwords api, google ads python, google ads token, google ads automation, google ads tutorial, google ads lib, google ads yaml, yaml api file, google ads developer token, google ads client id, google ads client secret, google ads refresh token, adwords reports, google ads api reports, google ads api python, google ads api python tutorial, google ads api setup, google ads api discovery campaigns, google adwords api tutorial
Id: ELzngMIgYts
Channel Id: undefined
Length: 17min 58sec (1078 seconds)
Published: Sat Jan 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.