CookieYes Consent Banner Action API
Last updated on June 2, 2025
On this page
Function
performBannerAction(action)Parameters
action (string): The action to be performed on the banner. Possible values are:
“accept_all“: Accepts all cookies, equivalent to clicking “Accept All” on the banner.“accept_partial“: Saves custom cookie preferences. Before calling this action, you must set the checkbox status for each cookie category using JavaScript.“reject“: Rejects all cookies, equivalent to clicking “Reject” on the banner.
Usage
Accept All Cookies
performBannerAction("accept_all");Reject All Cookies
performBannerAction("reject");Custom Preferences
// Update preferences in the UI using JavaScript
document.getElementById("<id of the checkbox>").checked = true;
document.getElementById("<id of the checkbox>").checked = false;
// Save the updated preferences
performBannerAction("accept_partial");
// This will save the preferences as set by the checkboxes.This example demonstrates how to update cookie preferences in the UI using JavaScript and then save those preferences using the performBannerAction function.
// Update preferences in the UI using JavaScript
// analytics
document.getElementById("ckySwitchanalytics").checked = true;
// advertisement
document.getElementById("ckySwitchadvertisement").checked = false;
// functional
document.getElementById("ckySwitchfunctional").checked = true;
// performance
document.getElementById("ckySwitchperformance").checked = false;
// other
document.getElementById("ckySwitchother").checked = false;
// Save the updated preferences
performBannerAction("accept_partial");
// This will save the preferences as set by the checkboxes.