Multiple trackers, tracking goals


I am trying to track goals for multiple trackers in piwik. Something like,

but how do i have to track goals for just piwik2 tracker and this happens in later point of time. So I have to define this tracker!!

var piwik2 = piwik2 || [ ];

and call the function

it is throwing an error like this:

Uncaught TypeError: piwik3.trackGoal is not a function

Can anyone help me with a solution?

See JavaScript Tracking Client: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3