在广告报告中从geo_target_constant获取名称

发布于 2025-02-05 12:43:18 字数 1596 浏览 1 评论 0原文

我正在使用ADS API根据美国的状态名称获得支出。

以下查询给出片段。geo_target_state将以ID返回而不是名称 我如何将此查询与

SELECT 
geo_target_constant.name, 
geo_target_constant.canonical_name 
FROM geo_target_constant 
WHERE geo_target_constant.id = <<OBTAINED ID FROM THE BELOW QUERY>>
curl "https://googleads.googleapis.com/v10/customers/${CUSTOMER_ID}/googleAds:searchStream" \
  --header "Content-Type: application/json" \
  --header "developer-token: ${DEVELOPER_TOKEN}" \
  --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \
  --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \
  --data '{
    "query": "
      SELECT
        campaign.name,
        segments.geo_target_state,
        metrics.cost_micros
      FROM geographic_view
      WHERE
        geographic_view.location_type = LOCATION_OF_PRESENCE
        AND segments.date BETWEEN 20220101 AND 20220430
    "
  }'

GeotargetConstants/21136结合到 “名称”:“新泽西”,

 "results": [
            {
                "campaign": {
                    "resourceName": "customers/1234/campaigns/1234",
                    "name": "Display - macines - Leads Display Campaign Test - AA"
                },
                "metrics": {
                    "costMicros": "66664821"
                },
                "segments": {
                    "geoTargetState": "**geoTargetConstants/21136**"
                },
                "geographicView": {
                    "resourceName": "customers/6383148790/geographicViews/2840~LOCATION_OF_PRESENCE"
                }
            },

I am using ads API for getting the spends based on state names of USA.

The below query gives segments.geo_target_state will be returned as an ID instead of name
How can I combine this query with

SELECT 
geo_target_constant.name, 
geo_target_constant.canonical_name 
FROM geo_target_constant 
WHERE geo_target_constant.id = <<OBTAINED ID FROM THE BELOW QUERY>>
curl "https://googleads.googleapis.com/v10/customers/${CUSTOMER_ID}/googleAds:searchStream" \
  --header "Content-Type: application/json" \
  --header "developer-token: ${DEVELOPER_TOKEN}" \
  --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \
  --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \
  --data '{
    "query": "
      SELECT
        campaign.name,
        segments.geo_target_state,
        metrics.cost_micros
      FROM geographic_view
      WHERE
        geographic_view.location_type = LOCATION_OF_PRESENCE
        AND segments.date BETWEEN 20220101 AND 20220430
    "
  }'

That is geoTargetConstants/21136 must be decoded to
"name": "New Jersey",

 "results": [
            {
                "campaign": {
                    "resourceName": "customers/1234/campaigns/1234",
                    "name": "Display - macines - Leads Display Campaign Test - AA"
                },
                "metrics": {
                    "costMicros": "66664821"
                },
                "segments": {
                    "geoTargetState": "**geoTargetConstants/21136**"
                },
                "geographicView": {
                    "resourceName": "customers/6383148790/geographicViews/2840~LOCATION_OF_PRESENCE"
                }
            },

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遗忘曾经 2025-02-12 12:43:19

如果要使用API​​查找GEO目标常数名称,则必须使用提供的查询来发布另一个搜索请求。

在一个关闭方案中,这可能是可以的,但是如果您需要检索多个GEO目标常数,则很快就会分解。

我为解决这一点所做的就是拉动地理目标列表,请参见: https://developers.google.com/google-ads/api/reference/data/geotargets ,然后将它们本地存储在数据库中。然后,我可以从必不可少的源中提取名称。

If you want to use the API to lookup the geo target constant name you will have to issue another search request using the query you provided.

This is likely okay in one off scenarios but breaks down quickly if you need to retrieve multiple geo target constants.

What I have do to resolve this is pull the list of geo targets, see: https://developers.google.com/google-ads/api/reference/data/geotargets, and store them locally in a database. Then I can pull the name from a must faster source.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文