What ever I do the custom variables were not getting saved into the
system. Finally I tried to track it down.
Which led me to core/Tracker/Request.php method getCustomVariables($scope) line
540 or so… where the $keyValue was being tested for count($keyValue) == 2
whereas it was still a json. From the js, it was being posted in as a dual json encoded
so I added
$keyValue = json_decode($keyValue, 1);
above the validation condition, just inside the foreach loop.
Now things are working as expected.