Userid tracking for multiple piwik instances

I’m having doubts on how to handle userids on multiple instances of piwik trackers.

We’re planning to log the userids as follows:
For siteid = 1, all userids who visited the site are logged.
For siteid = 2, if userid is included in the masterlist, userid is logged
For siteid = 3, else if userid is not included in the masterlist, userid is logged here.

var u="//piwik.example.org/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '1']);

_paq.push(["setUserId", "USER_ID_HERE"]);

// multiple trackers
_paq.push(['addTracker', piwikUrl = null, '2']);
_paq.push(['addTracker', piwikUrl = null, '3']);

// if USER_ID is included in masterlist 
// then setUserId in siteid 2, 
// else setUserId in siteId 3
onMasterList("USER_ID") ? _paq.push(["setUserId--in-siteid-2", "USER_ID_HERE"]) : _paq.push(["setUserId--in-siteid-3", "USER_ID_HERE"]); 

onMasterList is our function that checks if userid is included in the masterlist.