Posts tagged with google-ads-api

is there a way to easily call a GoogleAds API (TargetingIdeaService to be more precise) from Google Spreadsheet scripts? It looks like there should be an integratation of them but I'm missing it.

I can make calls to others APIs with no issues. I have registered myself on Google Ads and got a test token, which should be changed when I get the definitive one.

Thanks in advance.

I entered roughly 800 keywords in Keyword Planner for two target locations:

  • San Antonio TX, Texas, United States
  • San Jose, California, United States

The summary data for the Historical Metrics result set by Location is as follows:

I then added 18 more locations to the same keyword list to create this list of target locations.

  • Ann Arbor, Michigan, United States
  • Austin TX, Texas, United States Nielsen® DMA® regions
  • Cambridge, Massachusetts, United States
  • Cincinnati OH, United States Nielsen® DMA® regions
  • Columbia SC, South Carolina, United States Nielsen® DMA® regions
  • Fort Worth, Texas, United States
  • Greenville-Spartanburg-Asheville-Anderson, United States Nielsen® DMA® regions
  • Indianapolis IN, Indiana, United States Nielsen® DMA® regions
  • Jacksonville FL, United States Nielsen® DMA® regions
  • Miami, Florida, United States
  • New Haven County, Connecticut, United States county
  • Oakland, California, United States city
  • Orlando, Florida, United States city
  • Richmond-Petersburg VA, Virginia, United States Nielsen® DMA® regions
  • Salt Lake City UT, United States Nielsen® DMA® regions
  • San Antonio TX, Texas, United States Nielsen® DMA® regions
  • San Jose, California, United States
  • Syracuse NY, New York, United States Nielsen® DMA® regions
  • Trenton, New Jersey, United States city
  • Warsaw, Indiana, United States city

The summary data for this Historical Metrics result set by Location is as follows:

How does this make sense? Why would San Antonio disappear from the list? Why would the volume for San Jose go down?

Google Ads API, Their new version of the Google Adwords API returns data in a format called "GoogleAdsRow". I have not found any use at all for the information to be presented in this format and it is quite confusing. I want to print my file to a basic .csv format, but there is not any type of delimiter as far as i can tell. S far I have only been able to print each entire row as a single cell. Not Helpful :-).

My main function looks like this following. I have provided two examples of what I have tried with a comment block identifying both attempts:

def main(client, customer_id, page_size):     ga_service = client.get_service('GoogleAdsService', version='v2')     query = ('SELECT ad_group.id, ad_group_criterion.type, '              'ad_group_criterion.criterion_id, '              'ad_group_criterion.keyword.text, '              'ad_group_criterion.keyword.match_type FROM ad_group_criterion '              'WHERE ad_group_criterion.type = KEYWORD')     results = ga_service.search(customer_id, query=query, page_size=page_size)     try:         with open(path, "w", encoding = "utf-8", newline = "") as f:         #with open(path, "w") as csv:             csv_writer = csv.writer(f, delimiter=',')             for row in results:                 campaign = row.campaign                            csv_writer.writerow([row]) #Prints entire returned row as a single cell                 csv_writer.writerow(row) #Tells me there is no delimiter 

The iterable error is as follows

<ipython-input-15-e736ee2d05c9> in main(client, customer_id, page_size)      17                 campaign = row.campaign      18                 #csv_writer.writerow([row]) #Prints entire returned row as a single cell ---> 19                 csv_writer.writerow(row) #Tells me there is no delimiter      20       21  Error: iterable expected, not GoogleAdsRow 

I am new to Google AdWords API.

Right now I am downloading the AD_PERFORMANCE_REPORT and I want to segment it by day, but I cant find the right example in their documentation

My code looks like this:

 def get_data(customer_id):     df = None     for item in customer_id:         report_query = (adwords.ReportQueryBuilder()                         .Select('AdGroupId', 'AdGroupName', 'AbsoluteTopImpressionPercentage', 'Impressions', 'Conversions')                         .From('AD_PERFORMANCE_REPORT')                         .During('LAST_7_DAYS')                         .Build())         # You can provide a file object to write the output to. For this         # demonstration we use sys.stdout to write the report to the screen.         report_downloader.DownloadReportWithAwql(             report_query,             'CSV',             output,             client_customer_id=item,  # denotes which adw account to pull from             skip_report_header=True,             skip_column_header=False,             skip_report_summary=True,             include_zero_impressions=False)         output.seek(0)         df = pd.read_csv(output)         if df is None:             df = pd.DataFrame(output)         else:             df = df.append(pd.DataFrame(output))     return df 

Thank you for your suggestions.