c# - 如何通过 Google Adwords API 将自动标记设置为 true

标签 c# google-ads-api

我正在使用适用于 Google Adwords v201409 的 .NET 客户端库。

我可以使用 ManagedCustomer + ManagedCustomerService 创建帐户。
问题是 ManagedCustomer 没有我可以设置的自动标记字段。

我尝试使用 ManagedCustomer 创建一个新帐户,获取 CustomerId,然后使用 Customer + CustomerService,因为 Customer 具有 autoTagging 字段,但这不起作用 (USER_PERMISSION_DENIED)。我假设是因为创建新帐户时生成的 CustomerId 未与具有更改数据的正确权限的帐户关联。

那么我如何通过 API 创建一个新帐户并将 autoTagging 值设置为 TRUE 或创建一个新帐户然后将其 autoTagging 值更新为 TRUE?

最佳答案

好的。所以我解决了这个问题。

当我想要更新新创建的 ManagedCustomer 上的自动标记时,我实例化另一个 AdwordsUser 并将其 ClientCustomerId 更改为新创建的 ManagedCustomer customerId。然后我使用 Customer + CustomerService 来更新。

我按照 Google 提供的代码示例进行操作,这就是我实例化 AdwordsUser 的方法:

AdWordsUser adwordsUser = new AdWordsUser();
AdWordsAppConfig adwordsConfig = (AdWordsAppConfig)adwordsUser.Config;
adwordsConfig.ClientCustomerId = ENTER CUSTOMERID HERE;

这样,ClientId/ClientSecret/OAuthToken 可用于 API 调用,但 CustomerId 现在是新创建的 ManagedCustomer 的 CustomerId。因此,当我们更改 Customer 的 autoTagging 字段并更新它时,ManagedCustomers autoTagging 值就会按照我们想要的方式更新。

这是更新 autoTagging 字段的代码:

private void updateAdwordsCustomer(AdWordsUser adwordsUser)
{
CustomerService CustSer = (CustomerService)adwordsUser.GetService(
        AdWordsService.v201409.CustomerService);


    Customer customer = new Customer();
    customer.autoTaggingEnabled = true;

    var s = CustSer.mutate(customer);
}

关于c# - 如何通过 Google Adwords API 将自动标记设置为 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26914174/

相关文章:

c# - 如何在 ASP.NET MVC 中获取客户端的 IP 地址?

c# - 当进程提升时,如何获取非提升 session 的 Windows 身份验证 ID

google-analytics - 尝试将网络媒体资源链接到 AdWords (Google Ads) 帐户时出现权限不足 (403)

google-analytics - 如何修复 Google Adwords 代码的 "Both <script> and <iframe> used"建议

google-analytics - 在联系表单中显示 AdWords 广告系列

c# - Image.FromFile() 或 FromStream() 在 GdiplusStartup 上挂起

c# - 将地理分布表示为线性概率中的约束?

c# - ASP.NET MVC 5 如何使用来自不同类库的 View

javascript - 使用 OAuth 流程进行身份验证后,AdWords 范围 : gapi. client.adwords 丢失。找不到传递给gapi.client.request()的路径变量

google-analytics - 如何在 google adwords 中查看有区别的转化计数?