You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Adwords API获取指定广告系列的按日期排序报告?

How to Fetch a Single Campaign Report with Date Sorting via AdWords API

Absolutely! You can easily retrieve a report for just one specific campaign and have the results sorted by date using the AdWords API. Here's a practical breakdown of the steps and examples to implement this:

1. Core Report Query Logic

The key components are:

  • A WHERE clause to filter for your target campaign ID
  • Selecting the exact fields you need (CampaignID, AdgroupID, Impressions, Clicks, Date)
  • An ORDER BY clause to sort records by date

Example Report Query

For your required fields, the query would look like this:

SELECT CampaignId, AdGroupId, Impressions, Clicks, Date
FROM CAMPAIGN_PERFORMANCE_REPORT
WHERE CampaignId = '123456789'  -- Replace with your actual Campaign ID
ORDER BY Date ASC
  • Swap 123456789 with your campaign's unique ID
  • Use ASC for oldest-to-newest date order, or DESC for newest-to-oldest

2. Implementation with Python Client Library

Here’s how to execute this query using the official googleads library (adjust for your preferred language/client):

from googleads import adwords

# Initialize AdWords client (ensure your credentials are configured correctly)
client = adwords.AdWordsClient.LoadFromStorage()

# Get report downloader for your API version
report_downloader = client.GetReportDownloader(version='v201809')  # Use latest supported version

# Define your report query
report_query = (
    'SELECT CampaignId, AdGroupId, Impressions, Clicks, Date '
    'FROM CAMPAIGN_PERFORMANCE_REPORT '
    'WHERE CampaignId = "123456789" '
    'ORDER BY Date ASC'
)

# Download report as CSV (other formats like XML are supported too)
report_data = report_downloader.DownloadReportAsString(
    report_query,
    'CSV',
    client_customer_id='YOUR_CLIENT_CUSTOMER_ID',  # Replace with your account CID
    skip_report_header=False,
    skip_column_header=False,
    skip_report_summary=True,
    include_zero_impressions=False
)

# Process or print the results
print(report_data)

Key Notes

  • Report Type: We used CAMPAIGN_PERFORMANCE_REPORT here, but if you want ad-group-level focus, you can switch to ADGROUP_PERFORMANCE_REPORT (the filtering/sorting logic stays identical)
  • Zero Impressions: Set include_zero_impressions=True if you want to include days with no activity
  • API Version: Always use a currently supported API version to avoid compatibility issues

This will return a report containing only data for your specified campaign, sorted chronologically by date.

内容的提问来源于stack exchange,提问作者kishore

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:58:20