Search code examples
tagsgoogle-tag-manager

GTM API error vendorTemplate.parameter.eventName: The value must not be empty.\n


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"
}}

enter image description here


Solution

  • 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"
        }
    }