Skip to main content

JavaScript API Reference

Complete reference for the biskoui JavaScript SDK API methods, events, and data structures.

Global API Methods

All methods are available on the global window.biskoui object and are synchronous.

biskoui.showBanner()

Shows the consent banner to the user.

biskoui.showBanner();

Returns: void

Use case: Allow users to review or change their consent choices.


biskoui.hideBanner()

Hides the consent banner if currently visible.

biskoui.hideBanner();

Returns: void

Use case: Programmatically close the banner (rare use case).


biskoui.acceptAll()

Accepts all non-necessary categories and services. Necessary services remain always active. Automatically closes the consent banner.

biskoui.acceptAll();

Returns: void

Use case: Implement custom "Accept All" buttons or automatic acceptance flows.


biskoui.rejectAll()

Rejects all non-necessary categories and services. Only necessary services remain active. Automatically closes the consent banner.

biskoui.rejectAll();

Returns: void

Use case: Implement custom "Reject All" buttons or privacy-focused flows.


biskoui.acceptService(serviceId)

Accepts the specified service in addition to any previously accepted services. Does not affect other services' consent status. Necessary services remain always active. Automatically closes the consent banner.

biskoui.acceptService('google_analytics');
biskoui.acceptService('youtube');

Parameters:

  • serviceId (string): Service key to accept (must match dashboard configuration)

Returns: void

Use case: Implement progressive consent flows, feature-specific opt-ins, or additive consent controls.


biskoui.hasAcceptedService(serviceId)

Checks if a specific service has been accepted by the user.

const hasAnalytics = biskoui.hasAcceptedService('google_analytics');
const hasMaps = biskoui.hasAcceptedService('google_maps');

Parameters:

  • serviceId (string): The service key to check (must match dashboard configuration)

Returns: boolean

  • true if the service has been explicitly accepted
  • false if the service has been declined or no decision has been made yet

Use case: Check current consent status to conditionally load services or show UI elements.

Events

Service Activation Events

Per-Service Events

Fired when a specific service becomes activated (either through new consent or existing consent on page load).

Event Name Pattern: biskoui:<service_key>_activated

window.addEventListener('biskoui:google_maps_activated', function(event) {
// Google Maps is now allowed to run
initGoogleMaps();
});

window.addEventListener('biskoui:youtube_activated', function(event) {
// YouTube embeds are now allowed
loadYouTubeEmbeds();
});

Event Detail: None

Timing: Fires once per page load per service. If consent already exists, fires after SDK initialization.

Initialization Event

SDK Ready

Fired when the biskoui SDK has finished loading and is fully initialized.

Event Name: biskoui:ready

window.addEventListener('biskoui:ready', function(event) {
console.log('Biskoui SDK is ready');
// All SDK methods are now available
});

Event Detail: None

Timing: Fires once per page load after the SDK has completed initialization.

Script Blocking

Automatic Script Execution

Scripts with type="text/plain" and data-biskoui attributes are automatically executed when their corresponding service is activated.

<script type="text/plain" data-biskoui="google_analytics">
gtag('config', 'GA_MEASUREMENT_ID');
</script>

<script type="text/plain" data-biskoui="facebook_pixel">
fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
</script>

Attributes

type="text/plain" (required)

  • Prevents the browser from executing the script initially

data-biskoui="<service_key>" (required)

  • Links the script to a specific service configured in your biskoui dashboard
  • Service key must match exactly (snake_case format)

Behavior

  • Scripts execute once per page load when their service is activated
  • Execution is idempotent - duplicate scripts are ignored
  • Scripts execute in document order
  • Works for any service key present in your biskoui configuration

Service Key Format

All service keys use snake_case format and must be consistent across:

  • Dashboard service configuration
  • Event names: biskoui:<service_key>_activated
  • Script blocking: data-biskoui="<service_key>"
  • State object: state.services.<service_key>

Common Service Keys

  • google_analytics
  • google_maps
  • youtube
  • vimeo
  • facebook_pixel
  • google_ads
  • hotjar

Service keys are available in the services page in your biskoui dashboard.