Getting AdGroup Performance report for Custom Date - Adwords API using Python

2,059 views
Skip to first unread message

Varun Dhall

unread,
Jun 6, 2016, 9:14:09 AM6/6/16
to AdWords API Forum
Hello,

I am using standard python script to retrieve the data from my ad-words accounts.

Actually I want to fetch the data for a custom date like between '2016-06-01' to '2016-06-01' (YYYY-MM-DD)

Its really confusing and unclear how to modify this existing sample script 

# Create report definition.
  report = {
      'reportName': 'ADGROUP_PERFORMANCE_REPORT',
      'dateRangeType': 'CUSTOM_DATE',
      'reportType': 'ADGROUP_PERFORMANCE_REPORT',
      'downloadFormat': 'CSV',
      'selector': {
          'fields': ['Date', 'DayOfWeek', 'CampaignName', 'AdGroupName', 'Cost',
                     'Impressions', 'Clicks', 'AveragePosition', 'Conversions']
      }
  }

Its really great if someone can help me with proper report definition :)

Thanks!

Umesh Dengale

unread,
Jun 6, 2016, 10:54:26 AM6/6/16
to AdWords API Forum
Hello,

You could use custom date range as -  'dateRange':,{'min':[startDate], 'max':[endDate]}

Refer below example code. Please check out Reporting basics guide for more details.

  report = {
      'reportName': 'ADGROUP_PERFORMANCE_REPORT',
      'dateRangeType': 'CUSTOM_DATE',
      'reportType': 'ADGROUP_PERFORMANCE_REPORT',
      'downloadFormat': 'CSV',
      'selector': {
          'fields': ['Date', 'DayOfWeek', 'CampaignName', 'AdGroupName', 'Cost',
                     'Impressions', 'Clicks', 'AveragePosition', 'Conversions'],
           'dateRange':{'min':'20160601','max':'20160601'}

      }
  }

Regards,
Umesh, AdWords API Team.

Tushar Bhasin

unread,
Jun 28, 2017, 11:59:05 AM6/28/17
to AdWords API Forum
Hello, I get this error:

 'dateRange': {'min':'20170625','max':'20170625'}
                   ^
 SyntaxError: invalid syntax

Can you please explain?

Shwetha Vastrad (AdWords API Team)

unread,
Jun 28, 2017, 3:07:40 PM6/28/17
to AdWords API Forum
Hi Tushar, 

Could you provide the complete report definition so I can take a look? 

Thanks,
Shwetha, AdWords API Team.

Tushar Bhasin

unread,
Jun 29, 2017, 5:11:45 AM6/29/17
to AdWords API Forum
Hello Shwetha, 

Thank you for your reply, I am getting data using 'YESTERDAY' & 'TODAY' but not with custom date
Here is the definition:

report = {
        'reportName': 'CLICK_PERFORMANCE_REPORT',
        'dateRangeType': 'CUSTOM_DATE',
        'reportType': 'CLICK_PERFORMANCE_REPORT',
        'downloadFormat': 'CSV',
        'selector': {
            'fields': ['GclId', 'AccountDescriptiveName', 'CampaignId', 'CampaignName',
                       'AdGroupId', 'AdGroupName', 'CreativeId', 'CriteriaId',
                       'KeywordMatchType', 'AdNetworkType1', 'AdNetworkType2', 'Date',
                       'Device', 'Clicks', 'ClickType', 'Page', 'Slot', 'UserListId',
                       'LopCityCriteriaId', 'LopCountryCriteriaId', 'LopMostSpecificTargetId'],
            'dateRange' : {'min':'20170625','max':'20170625'}
        }
    }

Let me know 
Thanks 

Shwetha Vastrad (AdWords API Team)

unread,
Jun 29, 2017, 10:52:41 AM6/29/17
to AdWords API Forum
Hi Tushar, 

I was not able to find any errors in the report definition. Since this is a syntax error and not an API error, please send me the complete code so I can take a look. 

Tushar Bhasin

unread,
Jul 4, 2017, 5:44:07 AM7/4/17
to AdWords API Forum
Here is the complete code, please let me know about the problem?

def update_click_performance_report(account_name, client):

    report_downloader = client.GetReportDownloader(version='v201609')

    # Create report definition.
    report = {
        'reportName': 'CLICK_PERFORMANCE_REPORT',
        'dateRangeType': 'CUSTOM_DATE',
        'reportType': 'CLICK_PERFORMANCE_REPORT',
        'downloadFormat': 'CSV',
        'selector': {
            'fields': ['GclId', 'AccountDescriptiveName', 'CampaignId', 'CampaignName',
                       'AdGroupId', 'AdGroupName', 'CreativeId', 'CriteriaId',
                       'KeywordMatchType', 'AdNetworkType1', 'AdNetworkType2', 'Date',
                       'Device', 'Clicks', 'ClickType', 'Page', 'Slot', 'UserListId',
                       'LopCityCriteriaId', 'LopCountryCriteriaId', 'LopMostSpecificTargetId'],
            'dateRange' : {'min':'20170625','max':'20170625'}
        }
    }

    # Write report to a file
    if not os.path.exists('downloads'):
        os.makedirs('downloads')

    file = open('downloads/reports_click_performance_report.csv', 'wb')
    report_downloader.DownloadReport(
        report,
        file,
        skip_report_header=True,
        skip_column_header=True,
        skip_report_summary=True,
        include_zero_impressions=False)
    file.close()

Shwetha Vastrad (AdWords API Team)

unread,
Jul 5, 2017, 2:58:01 PM7/5/17
to AdWords API Forum
Hi Tushar, 

I was able to download a report using the above code snippet. I would suggest that you post your question on the Python client library's issue tracker so the library owners can help you out. 

Regards,
Shwetha, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages