Posts tagged with google-ads-api

Google has the following docs for the ad manager here. Unfortunately their example:

# Set the start and end dates of the report to run (past 8 days). end_date = date.today() start_date = end_date - timedelta(days=8) # Create report job. report_job = {     'reportQuery': {         'dimensions': ['LINE_ITEM_ID', 'LINE_ITEM_NAME'],         'columns': ['AD_SERVER_IMPRESSIONS', 'AD_SERVER_CLICKS',                     'AD_SERVER_CTR', 'AD_SERVER_CPM_AND_CPC_REVENUE',                     'AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM'],         'dateRangeType': 'CUSTOM_DATE',         'startDate': start_date,         'endDate': end_date     } } # Initialize a DataDownloader. report_downloader = client.GetDataDownloader(version='v202008') try:   # Run the report and wait for it to finish.   report_job_id = report_downloader.WaitForReport(report_job) except errors.AdManagerReportError as e:   print('Failed to generate report. Error was: %s' % e) with tempfile.NamedTemporaryFile(     suffix='.csv.gz', mode='wb', delete=False) as report_file:   # Download report data.   report_downloader.DownloadReportToFile(       report_job_id, 'CSV_DUMP', report_file) 

yields a KeyError: 'date' on the report_job_id line. My authorization is correct and I can make other calls with my client. My question is, how does one need to update report_job in order for the example to work. I tried changing 'dateRangeType' however this states it must be 'CUSTOM_DATE'.

If I enable Auto tagging for my Google ad URLs, is the gclid parameter the only parameter that gets added?

Like "?gclid=xyz123"?

No "utm_source" or "utm_medium" or anything else gets added as well?

Reason for confirming is the destination collecting the referral data says they can only handle on key/value parameter.

Thanks!

When you set up a campaign in google adwords you can add negative keywords to it so that the searchquery may not match your campaign if it has the negative keyword.

I want to extract the list of the negative keywords per each campaign. In the documentation I was able to find this example:

def retrieve_negative_keywords(report_utils)   report_definition = {     :selector => {       :fields => ['CampaignId', 'Id', 'KeywordMatchType', 'KeywordText']     },     :report_name => 'Negative campaign keywords',     :report_type => 'CAMPAIGN_NEGATIVE_KEYWORDS_PERFORMANCE_REPORT',     :download_format => 'CSV',     :date_range_type => 'TODAY',     :include_zero_impressions => true   }   campaigns = {}   report = report_utils.download_report(report_definition)   # Slice off the first row (report name).   report.slice!(0..report.index("\n"))   CSV.parse(report, { :headers => true }) do |row|     campaign_id = row['Campaign ID']     # Ignore totals row.     if row[0] != 'Total'       campaigns[campaign_id] ||= Campaign.new(campaign_id)       negative = Negative.from_csv_row(row)       campaigns[campaign_id].negatives << negative     end   end   return campaigns end 

Which is written in Ruby and there are no Python examples for this task. There is also a report for the negative keywords but it holds no metrics and I can't use it to retrieve the list of negative keywords per each campaign.

I am using this structure to query the database:

report_query = (adwords.ReportQueryBuilder()                         .Select('CampaignId', 'Id', 'KeywordMatchType', 'KeywordText')                         .From('CAMPAIGN_NEGATIVE_KEYWORDS_PERFORMANCE_REPORT')                         .During('LAST_7_DAYS')                         .Build()) 

But querying it gives an error:

googleads.errors.AdWordsReportBadRequestError: Type: QueryError.DURING_CLAUSE_REQUIRES_DATE_COLUMN

When I add Date it throws the same error.

Has anyone been able to extract the negative keyword list per campaign using Python with the Google Adwords API reports?

I am trying to connect to the google ads api using a service account. For analytics there is a good article named Hello Analytics API: Java quickstart for service accounts which explains how to set this up. For Google ads I can't find any documentation online.

So my two questions are:

  1. Is it possible to access the Google Ads API using a service account?
  2. If so, is there something like a Hello Ads API: Java quickstart for service accounts page with information on how to connect to the api with a service account?

UPDATE 2/10

I succeeded in passing the authentication fase. I do get an error when trying to fetch data from the API.

curl.exe --request POST "https://googleads.googleapis.com/v5/customers/******/googleAds:searchStream" --header "Content-Type: application/json"  --header "Authorization: Bearer ******"  --header "developer-token: ******"  --data "{'query': 'SELECT * FROM campaign WHERE segments.date DURING YESTERDAY'}" [{   "error": {     "code": 401,     "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",     "status": "UNAUTHENTICATED",     "details": [       {         "@type": "type.googleapis.com/google.ads.googleads.v5.errors.GoogleAdsFailure",         "errors": [           {             "errorCode": {               "authenticationError": "NOT_ADS_USER"             },             "message": "User in the cookie is not a valid Ads user."           }         ]       }     ]   } } ] 

The google docs say this error is because the account is not associated with an google ads account (https://developers.google.com/google-ads/api/docs/best-practices/common-errors#not_ads_user). The request are being processed by the api, I know this because the request are counted in the google ads api console as errors.

In the Credentials compatible with this API for the google ads Api my service account is listed. I am a little puzzled by the error. The service-account is associated with the google ads account as far as I could tell.

does anybody know if there is a way how to create a label for a keyword using Google Ads API? It can be done using the web interface and apparently it could be done using the Adwords API, but I can't find a way how to do it using Google Ads API so I don't know if it's a feature which they didn't implement or if I'm blind.

Their documentation says

Labels allow you to categorize your campaigns, ad groups, ads, and keywords, and use those categories to simplify your workflow in a variety of ways.

which would suggest that it CAN be done, however below on the same page it states

You can assign labels to your campaigns, customers, ad groups, criteria, or ads.

No word about keywords. I am working with PHP / Laravel and I am using their official php package for the API communication. The package has classes like CampaignLabelOperation, CustomerLabelOperation, AdGroupLabelOperation, etc. but NO "KeywordLabelOperation".

Anybody have a clue if I just can't find it or whatever I could do? Thanks a lot for any help