【问题标题】:Get full list of Adwords MCC with R使用 R 获取 Adwords MCC 的完整列表
【发布时间】:2020-02-26 21:09:17
【问题描述】:

我需要通过 Google API 和 R 获取所有具有 Adwords 帐户的 MCC 列表。 到目前为止,我已经找到了一些包来获取单个 MCC 中所有客户端 ID 的列表,但我没有找到获取 Adwords 帐户中所有 MCC 列表的示例。

有人有这方面的经验吗?

到目前为止我已经尝试过:

library(RAdwordsPlus)
library(RAdwords)

google_auth <- doAuth()

api_version <- "v201809"
customer_id <- "MCC-MAIN-CODE"

request <-  RAdwordsPlus::managed.customer.request(fields = c("Name", "CustomerId"))


r <- RAdwordsPlus::get.service(request     = request,
                 cid         = customer_id,
                 auth        = google_auth,
                 api.version = api_version,
                 user.agent  = "r-adwordsplus-test",
                 verbose     = FALSE,
                 raw = FALSE,
                 partial.failure = FALSE)

代码最终出现此错误:

Warning message:
In parser(response) : x is not a valid managed.customer

我的帐户结构类似于:

  • 主MCC

    • 客户 1 (client_id_1)

      • Camp_#1
      • Camp_#2
    • 客户 2 (client_id_2)

      • Camp_#1
      • Camp_#2
    • 客户 3 (client_id_3)

      • Camp_#1
      • Camp_#2

如上所述,我的目标是获取所有 client_id,以便为帐户中的每个客户收集数据

谢谢。

【问题讨论】:

  • 您能否发布一个可重现的示例,如果可以,我可以提供帮助 - 更多信息可在此处找到:stackoverflow.com/help/minimal-reproducible-example
  • 您尝试过哪些软件包,但未能使用?没有信息我会使用 RAdwords 以为我不知道您是否已经使用过它,或者问题出在您的代码上。
  • 在更新的问题中获得了我的部分代码。

标签: r google-ads-api


【解决方案1】:

看起来 JB 已经在他的文档中回答了您的问题:

https://jburkhardt.github.io/RAdwords/faq/#list-account-ids

列出帐户 ID

如何列出我的 MCC 中的所有 AdWords 帐户 ID?

我们很乐意实现此功能!不幸的是 Adwords API 报告服务不允许查询帐户信息 客户中心级别。

不过好在,您只需验证一次即可 访问您的 MCC 中的所有帐户。最佳实践是创建一个 包含帐户 ID 的向量并在向量上循环。

示例如下:

load('.google.auth.RData')

  adwords_accounts <- c(
  "495-862-1111",
  "613-408-2222",
  "564-802-3333",
  "902-758-4444",
  "536-035-5555",
  "708-304-6666",
  "429-737-7777",
  "532-474-8888")

  #
  account_performance <- statement(select= c('Date','AccountDescriptiveName','Cost','Clicks'),
                                            report="ACCOUNT_PERFORMANCE_REPORT",
                                            start="2019-01-01",
                                            end=as.character(Sys.Date()))
  #
  list_of_data <- lapply(adwords_accounts, function(x) getData(clientCustomerId = x, google_auth = google_auth, statement = account_performance))

  adwords_data <- do.call(rbind,list_of_data)

【讨论】:

  • 我看过代码,但我认为不是 100% 正确。我有一些 python 示例,可以在其中使用 API 获取 MCC 中的所有 client_id。此外,声明一个包含所有客户端代码的数组正是我想要避免的:-)。
  • 只是仔细检查,但您已通过 API 完成了有关 Google Ads 所需 API 密钥的步骤? jcchouinard.com/…
  • 当然,各种 API-KEY 已经在其他语言/实现上进行了测试
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-15
  • 2019-04-09
  • 2018-03-13
相关资源
最近更新 更多