Google Analytics分析API-RemarketingAudiences.insert仅在linkedAdAccounts为AD_WORDS时有效

问题描述

我正在编写Google Apps脚本,用于在Google Analytics(分析)中创建受众。我不断收到There was an internal error.

的非常无用的错误消息

根据[本指南] [1],我可以毫无问题地插入类型为AD_WORDS的新受众。但是,我当前的任务是复制ANALYTICS类型的受众。

我提交的资源的linkedAdAccounts属性似乎不正确。我可以看到官方文档提到了type的3种可能选项:ADWORDS_LINKSDBM_LINKSMCC_LINKSOPTIMIZE。不幸的是,除ADWORDS_LINKS之外,没有给出详细的解释。

这是被拒绝的有效载荷:

{
    name: "newName",linkedViews: ["123445677"],linkedAdAccounts: [
      {
        kind: "analytics#linkedForeignAccount",internalWebPropertyId: "12345678",status: "OPEN",remarketingAudienceId: "aaaaaaaaaaaaaaaaaaaaa",id: "xxxxxxxxxxxxxxxxxxxxx",webPropertyId: "UA-1234567-1",type: "ANALYTICS",accountId: "12345678",},],audienceType: "SIMPLE",audienceDeFinition: {
      includeConditions: {
        daysToLookBack: 7,segment: "users::condition::ga:sessionDuration>60",membershipDurationDays: 30,isSmartList: false,}

解决方法

事实证明,您无法为ANALYTICS linkedAdAccount添加ID。只需添加以下内容即可。

linkedAdAccounts: [
      {
        type: "ANALYTICS",},],