Skip to main content

The Pixel Manager Cookie Consent API

info

Since version 1.41.1 of the Pixel Manager

The Pixel Manager Cookie Consent API allows you to command the Pixel Manager if you are using a custom-made cookie consent banner. The API can also be used by publicly distributed Consent Management Platforms (CMPs) to integrate with the Pixel Manager.

Use the Pixel Manager Command Queue

You never know when the Pixel Manager is loaded. A shop manager might have enabled lazy loading in the Pixel Manager settings. Or, third-party plugins might load the Pixel Manager asynchronously. To make sure that the Pixel Manager is loaded before you call the API, use the Pixel Manager Command Queue (from version 1.49.0). The command queue is a global array called window._pmwq. You can push your commands to this array and they will be executed when the Pixel Manager is loaded (or executed immediately if the Pixel Manager is already loaded).

window._pmwq = window._pmwq || [];
window._pmwq.push(function () {
/// Add your command here
pmw.consent.api.acceptAll();
});

From version 1.65.0 queued commands run once the consent module is available, so the whole consent API can be called from inside the queue.

On version 1.64.0 and older the queue ran before the consent module had loaded. A consent call at the top level of a queued command then threw an error that the queue swallowed, which silently skipped the rest of that command. If you need to support those versions, call the API from an event handler instead, for example your cookie banner's click handler, which runs late enough on every version.

Accept all cookies and fire all pixels

pmw.consent.api.acceptAll();
pmw.consent.api.revokeAll();
pmw.consent.api.updateSelectively({
statistics: true,
marketing: false,
preferences: true,
necessary: true,
});

By default, the Pixel Manager saves the cookie consent indefinitely.

You can adjust this by passing the additional duration parameter (in an object).

pmw.consent.api.acceptAll({ duration: 30 });
pmw.consent.api.updateSelectively({
statistics: true,
marketing: false,
preferences: true,
necessary: true,
duration: 30,
});

Make more money from your ads with high-precision tracking