Multiple trackers, tracking goals

Hi,

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
piwik2.trackGoal(1);

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