英文:
GTM API error vendorTemplate.parameter.eventName: The value must not be empty.\n
问题
我正在尝试向https://developers.google.com/tag-platform/tag-manager/api/v2/reference/accounts/containers/workspaces/tags/create页面的GTM中添加一个新的标签。
在父级中,我使用以下值:
accounts/[123456789]/containers/[1234567]/workspaces/[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"
}}
英文:
I am trying to add a new tag to GTM on the page https://developers.google.com/tag-platform/tag-manager/api/v2/reference/accounts/containers/workspaces/tags/create.
In parent I use next value:
accounts/[123456789]/containers/[1234567]/workspaces/[1234567].
*
- in []
value for example.
In request body I write next data:
{
"name": "Test",
"type": "gaawc"
}
All time I getting the next error:
{"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"
}}
答案1
得分: 0
这是因为您正在使用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"
}
}
英文:
This is because you are using gaawc
tag type.
So there are some several required field in the payload.
You can not just send name : "test"
in this case.
You need to specify the measurementId
.
Go back to GTM UI and try to create a GA4 configuration tag. You can not save it without setting the measurement id. So the rule is same if you want to use the API to create tag.
If you are not sure what the payload should be.
The simple way is create the tag
in the GTM UI.
And export it as json file. You will see the actual json for the tag.
here is an example for test GA4 config tag
{
"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"
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论