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 ( )?
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.