如何修复通过 Google 标签管理器 API 更新标签时的 'invalidArgument' 错误?

How to fix the 'invalidArgument' error when updating a tag via Google Tag Manager API?

我正在尝试 运行 通过 GTM API 一个相对简单的更新语句。并且似乎得到了一个非常无意义的错误我的陈述如下:

{
  "parameter": [{
      "type": "template",
      "key": "html",
      "value": "test"
    },
    {
      "type": "boolean",
      "key": "supportDocumentWrite",
      "value": "false"
    }
  ]
}

我收到的错误是:

{
  "error": {
    "errors": [{
      "domain": "global",
      "reason": "invalidArgument",
      "message": "Unable to parse tag data"
    }],
    "code": 400,
    "message": "Unable to parse tag data"
  }
}

我也尝试了以下相同的结果:

{
  "liveOnly": false,
  "name": "Custom HTML - Form Field Tracking - Push Form Info to Data Layer",
  "type": "template",
  "parameter": [{
      "type": "template",
      "key": "html",
      "value": "TEST"
    },
    {
      "type": "boolean",
      "key": "supportDocumentWrite",
      "value": "false"
    }
  ],
  "priority": {
    "type": "integer",
    "value": "0"
  },
  "notes": "test"
}

我认为您第二次尝试的问题是 key/value "type": "template" 应该是 "type": "html"。我通过在标签管理器 url 中创建任意 html 标签,在 api 中显示该标签,然后复制模式来解决这个问题。因此,请尝试使用以下内容进行更新:

{
  "liveOnly": false,
  "name": "Custom HTML - Form Field Tracking - Push Form Info to Data Layer",
  "type": "html",
  "parameter": 
  [
    {
      "type": "template",
      "key": "html",
      "value": "TEST"
    },
    {
      "type": "boolean",
      "key": "supportDocumentWrite",
      "value": "false"
    }
  ],
  "priority": 
  {
    "type": "integer",
    "value": "0"
  },
  "notes": "test"
}