I’m looking for a way to bulk add custom dimensions to new sites, currently looking into the API (open to other solutions too!). I’ve been able to add a single CD at a time via API, and it seems that it’s (logically) dropped to the next available dimension slot.
There’s no mention in the documentation about POSTing several CDs at a time, and the JSON structure doesn’t seem to support it, but is it somehow possible now or perhaps in the future?
"name": "visitor hair color 2",
We have ~70 CDs in place on a bunch of sites, and to be able to use a Rollup to analyse the same CDs, we need to have them in the same exact slot for each site. We’ve done the adding manually so far (such a tedious and risk-prone process!), but for new sites we would like to get a way to copy the CD setup from existing sites.
You can achieve that by creating a script that would send those API calls multiple times with appropriate data.
e. g. The script would iterate through an array of objects that contains all the custom dimension-specific data (name, case_sensitive, active, scope) and send an API request per iteration. Then, you could use that script each time you add a new site for which you want to have the same set of custom dimensions.
API itself does not provide iteration like that, nor I’ve heard of plans like this.
Thanks for the tip!
Just to make sure, as the script would make the POST requests, the slots would be assigned in chronological order, right? Just thinking what error checking we would need. We would need to run the script in the right order, and have some response checker that would only allow the next POST after a 200 OK is received from the previous one.
Yes, you should check if request was OK before sending another one. Here’s a list of responses for creating a custom dimension: Object management API — Piwik PRO Analytics Suite 18.5 documentation