Hi! 
I'm using the following Python function to get criteria performance. And 
I'm getting lots of rows with different AdGroups and Criteria types, but 
all the performance stats like: Clicks, Impressions, etc. are just zeros. 
If I'm using additional filter in AWQL (Impressions > 1) I'm just getting 
empty df as result.
I'm requesting data from the last year in AWQL (tried many time intervals) 
and performance stats are not zeros in the UI even for one day. So it looks 
rather strange. am I missing something or is this a bug? Please help.

Python function:
import io
from googleads import adwords
import pandas as pd

def get_criteria_performance_report(report_downloader, start_date='20190502', 
end_date='20200502', criteria_type='AGE_RANGE'):
'''Function to get criteria statistics
Specs for the CRITERIA REPORT can be found here:
https://developers.google.com/adwords/api/docs/appendix/reports/criteria-performance-report#criteria
criteria_type (str): AGE_RANGE, GENDER, PARENT, INCOME_RANGE, ...
report_downloder should be created via:
adwords_client = 
adwords.AdWordsClient.LoadFromStorage(path='googleads.yaml')
report_downloder = adwords_client.GetReportDownloader(version='v201809')
'''

# Define output as a string
output = io.StringIO()

# Initialize appropriate service.
# report_downloader = client.GetReportDownloader(version='v201809')

# Create report query.
report_query = (adwords.ReportQueryBuilder()
.Select('CampaignName', 'CampaignId', 'AdGroupId',
'AdGroupName',
'Impressions', 'Clicks', 'AverageCpc', 'Labels',
'CriteriaType', 'Criteria',
'ConversionValue', 'AllConversionValue',
'ConversionRate',
'CampaignStatus', 'Cost')
.From('CRITERIA_PERFORMANCE_REPORT')
# .Where('Impressions').GreaterThan(1)
.Where('CriteriaType').In(criteria_type)
.During(start_date=start_date, end_date=end_date)
.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, skip_report_header=False,
skip_column_header=False, skip_report_summary=True,
include_zero_impressions=True)

output.seek(0)

df = pd.read_csv(output)
print(df)
df.reset_index(inplace=True)
df.columns = df.iloc[0]
df.drop(df.index[0], inplace=True)
df = df.astype({'Campaign ID': 'int', 'Cost': 'float',
'Clicks': 'float', 'Impressions': 'float'})
df.rename(columns={'Cost': 'CostMicroAmount',
}, inplace=True)

return df

if __name__ == '__main__':

adwords_client = adwords.AdWordsClient.LoadFromStorage(path='googleads.yaml'
)
report_downloader = adwords_client.GetReportDownloader(version='v201809')
result_df = get_criteria_performance_report(report_downloader)

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/b98f82e6-19e1-49a8-beea-547369c4d62b%40googlegroups.com.

Reply via email to