Events and API

Integrate other functions with the consent state

Alamarte Cookie Consent Pro provides JavaScript events and a public API that allow developers, extensions and scripts to check the current consent state, react when it changes and open or reset preferences from custom code.

This section is intended mainly for technical integrations.

You do not need to use the API or events for the normal operation of Alamarte Cookie Consent Pro. These features are useful when another script or extension needs to know or react to the consent state.

JavaScript events

Alamarte Cookie Consent Pro emits the following event:

alamarteCookieConsent

The event is emitted on document and can be listened for using standard JavaScript.

Public API

The API is available through the global object:

window.AlamarteCookieConsent

From this object you can check the current consent state, verify a category, open preferences or reset the saved decision.

Listen for consent events

Use document.addEventListener() to receive events emitted by Alamarte Cookie Consent Pro:

document.addEventListener('alamarteCookieConsent', function (event) {
    console.log(event.detail);
});

Event information is available in event.detail.

Information available in event.detail

Each event provides a structure containing the following information:

{
    type,
    consent,
    previousConsent,
    changes,
    source
}
  • type: indicates which type of event occurred.
  • consent: contains the current consent state.
  • previousConsent: contains the previous state when applicable.
  • changes: reports which categories were granted or revoked.
  • source: identifies the source of the change.

Available event types

The value of event.detail.type can be one of the following:

ready
loaded
accepted
rejected
custom
reset

These values allow you to identify the current stage of the system or which action the visitor has performed.

ready and loaded

These events allow you to detect the initialisation and loading of the consent system.

In these events, the granted and revoked category lists inside changes are empty.

accepted

This event is used when an acceptance decision is recorded.

An external integration can check the new state and act only on the categories it requires.

rejected

This event allows you to detect a rejection action and check the resulting consent state.

custom

This event is used when the visitor saves a custom selection of categories.

This makes it possible to determine which permissions have changed without assuming that all categories share the same state.

reset

This event allows you to detect that the saved consent has been reset.

Integrations that depend on consent can use this event to check their state again before performing new actions.

Granted and revoked categories

In events related to a choice or consent reset, changes allows you to check which categories changed:

event.detail.changes.granted
event.detail.changes.revoked

This is useful when an integration needs to react only to permissions that actually changed.

Available public API

Alamarte Cookie Consent Pro exposes the following methods:

window.AlamarteCookieConsent.getConsent()

window.AlamarteCookieConsent.hasConsent('analytics')

window.AlamarteCookieConsent.openPreferences()

window.AlamarteCookieConsent.resetConsent()

getConsent()

Returns the current consent state from JavaScript.

const consent =
    window.AlamarteCookieConsent.getConsent();

hasConsent()

Checks whether consent is available for a specific category.

For example, to check the Analytics category:

window.AlamarteCookieConsent.hasConsent('analytics')

openPreferences()

Opens the consent preferences interface from JavaScript.

window.AlamarteCookieConsent.openPreferences();

It can be used, for example, from a custom control created by the site.

resetConsent()

Resets the consent managed by Alamarte Cookie Consent Pro from JavaScript.

window.AlamarteCookieConsent.resetConsent();

Example: check a category after a change

An integration can listen for the event and then check whether the required consent is available:

document.addEventListener('alamarteCookieConsent', function (event) {

    if (
        window.AlamarteCookieConsent.hasConsent('analytics')
    ) {
        console.log('Analytics authorised');
    } else {
        console.log('Analytics not authorised');
    }

});

Replace the example actions with the specific logic required by the integration you are developing.

Important: an external integration that requires consent should remain inactive until the required category has been granted. The cookie, API and events provide technical information about the consent state, but on their own they do not constitute legal proof of consent.

trustpilot horizontal

© 2026 Alamarte Ingeniería
Joomla! Design & Development
colombia CO CO

Alamarte Ingeniería Web
Trustpilot
Joomla!
Cookie preferences saved.