Search code examples
google-tag-manager

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


I am trying to run a relatively simple update statement via the GTM API. and seem to be getting a very uninformative error my statement is as follows:

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

The error I receive is:

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

I have also tried the following with the same results:

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

Solution

  • I believe that your problem with your second attempt is that the key/value "type": "template" should be "type": "html". I figured this out by creating an arbitrary html tag in the tag manager url, displaying that tag in the api, and then copying the pattern. So, try updating with the following:

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