Editing Piwik Pro Config Tag via HTTP API does not work

Hello,
I am trying to edit the Piwik Pro Tag via the HTTP API.

But I always get Status Code: 400,
Response:

{
  "errors": [
    {
      "meta": {
        "keyword": "$schema",
        "keyword_args": {
          "schema": false
        }
      },
      "code": "INVALID_JSON_ERROR",
      "detail": "The attribute \"\/data\/attributes\/template_options\/tracker_js_url\" is invalid.",
      "source": {
        "pointer": "\/data\/attributes\/template_options\/tracker_js_url"
      }
    },
    {
      "meta": {
        "keyword": "$schema",
        "keyword_args": {
          "schema": false
        }
      },
      "code": "INVALID_JSON_ERROR",
      "detail": "The attribute \"\/data\/attributes\/template_options\/tracker_php_url\" is invalid.",
      "source": {
        "pointer": "\/data\/attributes\/template_options\/tracker_php_url"
      }
    },
    {
      "meta": {
        "keyword": "$schema",
        "keyword_args": {
          "schema": false
        }
      },
      "code": "INVALID_JSON_ERROR",
      "detail": "The attribute \"\/data\/attributes\/template_options\/tracker_site_id\" is invalid.",
      "source": {
        "pointer": "\/data\/attributes\/template_options\/tracker_site_id"
      }
    },
    {
      "meta": {
        "keyword": "$schema",
        "keyword_args": {
          "schema": false
        }
      },
      "code": "INVALID_JSON_ERROR",
      "detail": "The attribute \"\/data\/attributes\/template_options\/tracker_domains\" is invalid.",
      "source": {
        "pointer": "\/data\/attributes\/template_options\/tracker_domains"
      }
    },
    {
      "meta": {
        "keyword": "$schema",
        "keyword_args": {
          "schema": false
        }
      },
      "code": "INVALID_JSON_ERROR",
      "detail": "The attribute \"\/data\/attributes\/template_options\/set_ip_tracking\" is invalid.",
      "source": {
        "pointer": "\/data\/attributes\/template_options\/set_ip_tracking"
      }
    },
    {
      "meta": {
        "keyword": "$schema",
        "keyword_args": {
          "schema": false
        }
      },
      "code": "INVALID_JSON_ERROR",
      "detail": "The attribute \"\/data\/attributes\/template_options\/strict_privacy_mode\" is invalid.",
      "source": {
        "pointer": "\/data\/attributes\/template_options\/strict_privacy_mode"
      }
    }
  ]
}

So it is sth with template_options. My assumption was that to edit it, I just change the attributes I want to change (in my case, the names of the Variables in the Custom Dimension Mapping) and send the rest as it was. But it seems Piwik does not like some of the attributes even though I send them back exactly as they existed. (eg tracker_php_url).

The documentation says nothing about which attributes I need to leave out when sending an EDIT request: Tags — Piwik PRO Analytics Suite 18.28 documentation

My request body (yes, “XXX” stands for correct values that I cannot show here):

{
  "data" : {
    "id" : "27136e43-c45d-47f7-95db-e9cd18ede8fc",
    "type" : "tag",
    "attributes" : {
      "is_active" : true,
      "priority" : 3,
      "name" : "P:stg.pageView - Piwik Pro - Config (prioritized)",
      "consent_type" : "not_require_consent",
      "disable_in_debug_mode" : false,
      "respect_visitors_privacy" : false,
      "scheduler" : {
        "date_ranges" : [ ],
        "times_of_day" : [ ]
      },
      "template_options" : {
        "link_tracking" : false,
        "cross_domain_tracking" : false,
        "secure_cookie" : true,
        "js_error_tracking" : true,
        "track_page_view" : false,
        "heart_beat_timer" : {
          "enabled" : true
        },
        "piwik_custom_dimensions" : [ {
          "id" : 1,
          "value" : "{{ G:location.href - JS }}"
        }, {
          "id" : 2,
          "value" : "{{ G:location.pathname - JS }}"
        }, {
          "id" : 3,
          "value" : "{{ G:site_country - JS }}"
        }, {
          "id" : 4,
          "value" : "{{ G:site_language - JS }}"
        }, {
          "id" : 5,
          "value" : "{{ Referrer }}"
        }, {
          "id" : 6,
          "value" : "{{ G:hreflang x-default URL + Query String - JS }}"
        }, {
          "id" : 9,
          "value" : "{{ G:document.title - DOC }}"
        }, {
          "id" : 10,
          "value" : "{{ G:location.hash - JS }}"
        }, {
          "id" : 11,
          "value" : "{{ Event }}"
        }, {
          "id" : 12,
          "value" : "{{ G:navigator.userAgent - JS }}"
        }, {
          "id" : 16,
          "value" : "{{ G:URL Parameter List - JS }}"
        }, {
          "id" : 17,
          "value" : "{{ G:hreflang x-default URL Path Hierarchy L1 - JS }}"
        }, {
          "id" : 18,
          "value" : "{{ G:hreflang x-default URL Path Hierarchy L2 - JS }}"
        }, {
          "id" : 19,
          "value" : "{{ G:hreflang x-default URL Path Hierarchy L3 - JS }}"
        }, {
          "id" : 20,
          "value" : "{{ G:hreflang x-default URL Path Hierarchy L4 - JS }}"
        }, {
          "id" : 29,
          "value" : "{{ G:query decoded - JS }}"
        }, {
          "id" : 30,
          "value" : "{{ G:hreflang x-default URL without Query - JS }}"
        }, {
          "id" : 31,
          "value" : "{{ G:utm_variant - GET }}"
        } ],
        "tracker_js_url" : "https://XXX.containers.piwik.pro/ppms.js",
        "tracker_php_url" : "https://XXX.piwik.pro/ppms.php",
        "tracker_site_id" : "XXXXXXX",
        "tracker_domains" : [ "https://www.xxxx.com" ],
        "set_ip_tracking" : true,
        "strict_privacy_mode" : false
      }
    }
  }
}

So does Piwik Pro expect me to try with and without each and every attribute until it works ( :sweat_smile:)?

EDIT: I believe these are values that are either sunset (no longer visible in the UI, but still in the API) or cannot be changed anyway. But I still think Piwik should handle this better. Either not return attributes in the first place that cannot be edited, or mention in the docs clearly what can be edited or not, or simply ignore it if the old and new value is the same (= no edit) and only throw an error if somebody really tried to change these values, and in any case not return a cryptic “is invalid” error.

Hi @loldenburg,

Certain attributes are returned in the GET response, but this doesn’t necessarily mean they are editable (PATCH request in this scenario). For example, fields like order number or payment amount in an online store are typically non-editable.

The API documentation specifies which fields can be modified. Additionally, when using a PATCH request, you can update individual fields without sending the entire resource.

The response includes an error description, indicating that the following attributes are not allowed and are not mentioned in the API documentation:

•	tracker_js_url
•	tracker_php_url
•	tracker_site_id
•	tracker_domains
•	set_ip_tracking (this one isn’t even in the GET)
•	strict_privacy_mode (this one isn’t in the GET either)

Thanks, but where does the API doc specify that?

Here I see only a very simple “abtasty” example.
The template_options part also only refers to that abtasty Tag:

You should be able to select other templates from the lists, as shown in the screenshot.

Thanks, I even tried that in the past, but since nothing directly happens when you click it I didn’t realize that what changes is only visible once you open the “data” object.
I was expecting the payload examples on the right side to change, but there you always just see the “ab tasty” tag. Not sure if that is as designed or a bug.

All in all: Maybe not too intuitive, maybe partially broken (payload examples not updating to template), maybe just me being stupid. A little explanation text above the template selector would help.

Thanks for your help in any case.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.