我正在尝试在页面上向 GTM 添加新标签https://developers.google.com/tag-platform/tag-manager/api/v2/reference/accounts/containers/workspaces/tags/create。
在父级中我使用下一个值: 帐户/[123456789]/容器/[1234567]/工作空间/[1234567].
*
- 例如 []
值。
在请求正文中我写入下一个数据:
{
"name": "Test",
"type": "gaawc"
}
我一直收到下一个错误:
{"error": {
"code": 400,
"message": "vendorTemplate.parameter.measurementId: The value must not be empty.\n",
"errors": [{
"message": "vendorTemplate.parameter.measurementId: The value must not be empty.\n",
"domain": "global",
"reason": "badRequest"
}],
"status": "INVALID_ARGUMENT"
}}
这是因为您使用的是
gaawc
标签类型。
因此有效负载中有一些必填字段。
在这种情况下,您不能只发送
name : "test"
。
您需要指定
measurementId
。
返回 GTM UI 并尝试创建 GA4 配置标记。如果不设置测量 ID,则无法保存。所以如果你想使用 API 创建标签,规则是一样的。
如果您不确定有效负载应该是什么。
最简单的方法是在 GTM UI 中创建
tag
。
并将其导出为json文件。您将看到标签的实际 json。
这是测试 GA4 配置标记的示例
{
"accountId": "3853417116",
"containerId": "9675477",
"tagId": "6",
"name": "test-ga4-config-tag",
"type": "gaawc",
"parameter": [
{
"type": "BOOLEAN",
"key": "sendPageView",
"value": "true"
},
{
"type": "BOOLEAN",
"key": "enableSendToServerContainer",
"value": "false"
},
{
"type": "TEMPLATE",
"key": "measurementId",
"value": "G-000000"
}
],
"fingerprint": "1691569014795",
"firingTriggerId": [
"2147479553"
],
"tagFiringOption": "ONCE_PER_EVENT",
"monitoringMetadata": {
"type": "MAP"
},
"consentSettings": {
"consentStatus": "NOT_SET"
}
}