Ppms not defined

Hi all,
I am working on a Piwik Pro Integration and instead of using the Piwik Pro script, I am using this one :

var _paq = _paq || [];
  _paq.push(['setCustomUrl', "/" + {{Macro - Langue}} + "/#/" + {{Macro - FragmentNew}}]);
  _paq.push(['setDocumentTitle', document.title ]);
  _paq.push(['trackPageView']);
  _paq.push(["enableLinkTracking"]);
  (function() {
    var u="https://XXXXX.piwik.pro/";
    _paq.push(["setTrackerUrl", u+"ppms.php"]);
    _paq.push(["setSiteId", {{Tableau - Hostname}}]);
    var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0];
    g.type="text/javascript"; g.async=true; g.defer=true; g.src=u+"ppms.js"; s.parentNode.insertBefore(g,s);
  })();
  

As we already use a Consent Management Platform on the website, we use this script to send the cookie choice made by the user. This one, is when the page is loading

ppms.cm.api(
  "setInitialComplianceSettings",
  { consents: ["analytics"] },
  function () {},
  function () {}
);

This one is when th user made his choice (Analytics cookies accepeted)

ppms.cm.api(
  "setComplianceSettings",
  { consents: { analytics: { status: 1 } } },
  function () {},
  function () {}
);

But when I checked the browser console, I have this error “Uncaught ReferenceError: ppms is not defined”. I imagine that it is because I’m not using the Piwik Pro container.
My question is, how can I send the cookie choice information to Piwik without using the piwik container script ?

I found this script maybe it could be a solution ?

    _paq.push(["setUserIsAnonymous", true]);
    _paq.push(["setUserIsAnonymous", false]);
 

Thank you
Regards
Pascal

Hello @pascal,

You are right, ppms.cm.api is only available with the main container snippet (that includes Tag Manager and Consent Manager).

_paq.push(["setUserIsAnonymous", true]) enables anonymization when consent is not given. To disable anonymization when consent is given, you would need to then add _paq.push(["deanonymizeUser"]).

Another approach would be to wait until consent is given before loading our code, but then you would not get any anonymized data for sessions where consent was not explicitly provided.

Thank you very much for your support.
Best Regards
Pascal