# CookieYes Events on Cookie Banner Load

Learn best practices for setting up early event listeners to effectively handle the CookieYes banner load event.

---

**Categories:** , 
**Published:** July 28, 2026
**URL:** https://www.cookieyes.com/documentation/events-on-cookie-banner-load/

---

## Overview

The CookieYes banner load event allows users to execute custom actions when the consent banner is loaded on a webpage. This document outlines how to use the `cookieyes_banner_load` event and the data it provides.

> **Note:**

> **Incompatible for CookieYes WordPress plugin without Web App Connection.**
> The event listeners mentioned in this documentation are incompatible with the CookieYes WordPress plugin when not connected to the web app. However, they seamlessly function with both the web app and the WordPress plugin when it is connected to the web app.
>

## Event Listener

To utilize the CookieYes banner load event, add an event listener to the `document` object for the `cookieyes_banner_load` event. When the event is fired, the event listener triggers a callback function, providing the event data as an argument.

## Basic Usage

To implement the event listener into your website, add the following code snippet to your webpage. Check the `JSON` value in `eventData` and customize the code to execute the specific action you want.

```js
document.addEventListener("cookieyes_banner_load", function (eventData) {
    //  Check the value in the JSON eventData and perform the desired action.
})
```

## Event Data Structure 

The `JSON` object `eventData` includes the user's consent choices for different cookie categories, consent ID, the active consent law, the language code of the displayed banner, and whether the user has interacted with the cookie consent banner in the below format.

```js
detail: {
    "activeLaw": "String",           // e.g., "gdpr", "ccpa", etc.
    "categories": {
        "necessary": "Boolean",       
        "functional": "Boolean",      
        "analytics": "Boolean",       
        "performance": "Boolean",     
        "advertisement": "Boolean"    
    },
    "isUserActionCompleted": "Boolean", // true or false
    "consentID": "String",           // Unique identifier for the consent
    "languageCode": "en"             // e.g., "en" for English
}
```

The key properties are:

| Property | Type | Description |
| --- | --- | --- |
| activeLaw | string | The legal framework under which the consent is active. |
| categories | object | User consent status for different categories. |
| isUserActionCompleted | boolean | Indicates whether the user interacted with the banner. |
| consentID | string | Unique identifier for the user's consent. |
| languageCode | string | [a href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes" target="_blank"]ISO-639-1[/a] code of the displayed banner language. |

## Example Usage

Here's an example of how to use the event listener to perform a specific action when the active law is "`gdpr`":

```html
<script>
 document.addEventListener("cookieyes_banner_load", function (eventData) {
    const data = eventData.detail;
   if (data.activeLaw === "gdpr") {
     // perform the desired action.
   }
  });
</script>
```

The `JSON` object `eventData` contains the following information:

```html
detail: {
  "activeLaw": "gdpr",
  "categories": {
    "necessary": true,
    "functional": false,
    "analytics": false,
    "performance": false,
    "advertisement": false
  },
  "isUserActionCompleted": true,
  "consentID": "bFl2eFJBN05VS21WNWk5enpRNTNEZ3hxR0dDc3VmcFM",
  "languageCode": "en"
}
```

## Best Practices

- **Handle potential errors: **When working with event data, it's crucial to anticipate and manage scenarios where errors might occur due to unexpected data formats or processing issues. Your code should be prepared to handle these scenarios without crashing or behaving unpredictably.
- **Respect User Consent: **Consider the user's consent status when performing actions based on this event.  Before initializing any scripts, loading content or performing actions that might involve user data, you should check the relevant consent status.
- **Add the handler early in the page: **To ensure your handler is in place in time to catch the event, place the event listener for `cookieyes_banner_load` as early as possible in your page's loading sequence. This guarantees the handler is ready when the event fires, which often occurs very early in the page load process.
- **Use a combination of banner load and interaction events: **[Implement](https://www.cookieyes.com/documentation/events-on-cookie-banner-interactions/)`cookieyes_consent_update`[listener](https://www.cookieyes.com/documentation/events-on-cookie-banner-interactions/)within the handler of `cookieyes_banner_load`* *to cover all scenarios. This approach ensures you capture both the initial consent state and any subsequent user interactions with the banner, providing a comprehensive consent management strategy.


---

## Structured Data

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Article",
      "headline": "CookieYes Events on Cookie Banner Load",
      "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "https://www.cookieyes.com/documentation/events-on-cookie-banner-load/"
      },
      "url": "https://www.cookieyes.com/documentation/events-on-cookie-banner-load/",
      "publisher": {
        "@type": "Organization",
        "name": "CookieYes",
        "url": "https://www.cookieyes.com",
        "logo": {
          "@type": "ImageObject",
          "url": "https://assets.cookieyes.com/cookieyes.png",
          "width": 250,
          "height": 60
        }
      },
      "description": "Learn best practices for setting up early event listeners to effectively handle the CookieYes banner load event.",
      "datePublished": "2024-07-07T02:58:19+00:00",
      "dateModified": "2025-06-02T06:23:49+00:00",
      "author": {
        "@type": "Person",
        "name": "CookieYes Doc Team"
      },
      "image": [
        "https://assets.cookieyes.com/Cookieyes_logo_65b0e62114.png"
      ]
    },
    {
      "@type": "BreadcrumbList",
      "@id": "https://www.cookieyes.com/documentation/events-on-cookie-banner-load/#breadcrumb",
      "itemListElement": [
        {
          "@type": "ListItem",
          "position": 1,
          "name": "Home",
          "item": "https://www.cookieyes.com/"
        },
        {
          "@type": "ListItem",
          "position": 2,
          "name": "Documentation",
          "item": "https://www.cookieyes.com/documentation/"
        },
        {
          "@type": "ListItem",
          "position": 3,
          "name": "Features Documentation",
          "item": "https://www.cookieyes.com/category/documentation/features/"
        },
        {
          "@type": "ListItem",
          "position": 4,
          "name": "Events",
          "item": "https://www.cookieyes.com/category/documentation/features/event-listener/"
        },
        {
          "@type": "ListItem",
          "position": 5,
          "name": "CookieYes Events on Cookie Banner Load"
        }
      ]
    },
    {
      "@type": "WebSite",
      "@id": "https://www.cookieyes.com/#website",
      "url": "https://www.cookieyes.com/",
      "name": "CookieYes",
      "description": "CookieYes is a Google-certified consent management platform that helps businesses comply with GDPR, CCPA, and other global privacy laws.",
      "inLanguage": "en-US",
      "publisher": {
        "@id": "https://www.cookieyes.com/#organization"
      },
      "potentialAction": {
        "@type": "SearchAction",
        "target": {
          "@type": "EntryPoint",
          "urlTemplate": "https://www.cookieyes.com/?s={search_term_string}"
        },
        "query-input": {
          "@type": "PropertyValueSpecification",
          "valueRequired": true,
          "valueName": "search_term_string"
        }
      }
    },
    {
      "@type": "Organization",
      "@id": "https://www.cookieyes.com/#organization",
      "name": "CookieYes",
      "url": "https://www.cookieyes.com/",
      "logo": {
        "@type": "ImageObject",
        "@id": "https://www.cookieyes.com/#/schema/logo/image/",
        "inLanguage": "en-US",
        "url": "https://assets.cookieyes.com/cookieyes.png",
        "contentUrl": "https://assets.cookieyes.com/cookieyes.png",
        "width": 19701,
        "height": 3176,
        "caption": "CookieYes"
      },
      "image": {
        "@id": "https://www.cookieyes.com/#/schema/logo/image/"
      }
    }
  ]
}
```
