Tracker already initiated when tracking custom consent form clicks

I have a custom form for consent settings.
When the visitors click accept all, this code is executed:

document.querySelector(BAR_AGREE_TO_ALL_ID).addEventListener('click', function() {
  agreeToAll();
  ppms.cm.api('trackAgreeToAllClick', cbSuccess, console.error);
});

But then I receive this error in the console:

Matomo javascript tracker or Piwik PRO javascript tracker was already initiated on this page. Please check the tracker setup. Matomo conflict can be resolved using these instructions: Can I use Piwik PRO and Matomo at the same time? | Piwik PRO help center.

When I comment the click tracker, the error is gone:

document.querySelector(BAR_AGREE_TO_ALL_ID).addEventListener('click', function() {
  agreeToAll();
  //ppms.cm.api('trackAgreeToAllClick', cbSuccess, console.error);
});

Does anyone has an idea what goes wrong here?