Overview

Use the ppms.cm.api method to call Consent Manager commands from JavaScript.

After you install the container code on your site, it creates the _paq queue. Commands are added to the queue and executed after the library loads.

Syntax

ppms.cm.api(command, ...args)

Parameters

command: string (required)

Command name.

args (optional)

Command arguments. The number of arguments and their meaning depend on the command.

Returns

Commands run asynchronously and return no value. Type: undefined.

Notes

  • All commands work in the context of the current visitor and website. Some commands communicate with a Piwik PRO server and are asynchronous.
  • Callback functions provide response values or error information.
  • onSuccess(...args) is required for getComplianceSettings, getComplianceTypes, getNewComplianceTypes, sendDataRequest, setComplianceSettings and setInitialComplianceSettings. It is optional for openConsentForm and tracking commands.
  • onFailure(error) is optional. If specified, it receives an object. If not specified, the error is logged in the console.
  • Command pages use TypeScript-style callback signatures, for example, onFulfilled: (settings: ComplianceSettings) => void.

Available consent types

Here are the types of consent that are available:

  • analytics
  • ab_testing_and_personalization
  • custom_consent
  • user_feedback
  • marketing_automation
  • remarketing
  • conversion_tracking

Consent status values

The following status values are used in consents[type].status:

  • -1: No decision. Returned only by getComplianceSettings. For example, a visitor closes the consent popup without making a choice.
  • 0: Rejected
  • 1: Approved