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?