如何在 Google Ads API 查询中嵌入自定义滚动日期范围?
我正在利用 Google 广告 API 来提取广告系列数据,但遇到一个问题,我想在查询中使用固定日期范围,但它似乎无法作为 文档。
这是我的查询:
GAquery = """
SELECT
segments.date,
segments.device,
campaign.name,
metrics.clicks,
metrics.conversions,
metrics.conversions_value,
metrics.cost_micros,
metrics.impressions
FROM
campaign WHERE segments.date DURING LAST_30_DAYS
ORDER BY
metrics.clicks DESC"""
# Issues a search request using streaming.
response = ga_service.search_stream(customer_id=customer_id, query=GAquery)
我希望获取 LAST_60_DAYS 而不是 30,但将 LAST_30_DAYS 更改为 LAST_60_DAYS 错误。有没有人找到一种方法来编码不是系统中预设选项的滚动日期范围,或者我们是否只使用预设选项?
非常感谢您的帮助。 :)
I am utilizing the Google ads API to pull campaign data and I am having an issue where I would like to use a fixed date range in my query, but it seems to be unavailable as an option in the documentation.
Here is my query:
GAquery = """
SELECT
segments.date,
segments.device,
campaign.name,
metrics.clicks,
metrics.conversions,
metrics.conversions_value,
metrics.cost_micros,
metrics.impressions
FROM
campaign WHERE segments.date DURING LAST_30_DAYS
ORDER BY
metrics.clicks DESC"""
# Issues a search request using streaming.
response = ga_service.search_stream(customer_id=customer_id, query=GAquery)
I am looking to get the LAST_60_DAYS instead of 30, but changing the LAST_30_DAYS to LAST_60_DAYS errors out. Has anyone found a way to code a rolling date range that is not a preset option in the system or are we stuck with only the preset options?
Thanks so much for your help. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您链接到的预定义日期范围是唯一存在的。
如果您需要与可用选项不同的时间范围,则必须自行计算开始日期和结束日期,并使用带有
segments.date BETWEEN '' 的自定义日期范围AND“”
。The predefined date ranges you linked to are the only ones that exist.
If you need a different time range than the available options, you're going to have to calculate the start and end dates yourself and use a custom date range with
segments.date BETWEEN '<START_DATE>' AND '<END_DATE>'
.只需自己创建变量名称并将它们插入到查询中即可。
然后在您的查询中:
Simply create the variable names yourself and insert them into the query.
Then in your query: