# Retrieving Consent Data Using getCkyConsent() API

Learn the use and implementation of getCkyConsent() API to easily access categorized cookie consent data from CookieYes banners.

---

**Categories:** , 
**Published:** July 27, 2026
**URL:** https://www.cookieyes.com/documentation/retrieving-consent-data-using-api-getckyconsent/

---

## Overview

CookieYes has introduced a new API function, getCkyConsent() allowing you to access consent data sorted by consent types easily. This function returns an object containing details about:

- Your consent choices for different cookie categories (necessary, functional, analytics, advertisement, etc.)

- Whether you have interacted with a cookie consent banner.

- Your unique consent ID.

- The active consent law (like GDPR) applicable to the website.

- The language code of the displayed banner

## Using getCkyConsent()

> The `getCkyConsent() `function is available **only after the CookieYes banner has fully loaded**. To ensure the API is accessible, use the `cookieyes_banner_loaded` event. See [CookieYes Events on Cookie Banner Load](https://www.cookieyes.com/documentation/events-on-cookie-banner-load/) for more details.
>

Call getCkyConsent() to retrieve the consent data:
`getCkyConsent();`
It returns an object containing the consent data:

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

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 | ISO-639-1 code of the displayed banner language. |

> **Note:**

> The `getCkyConsent() `function will not retrieve consent data if the CookieYes banner is disabled or the website is suspended. In such cases, the API will not be available.
>

## Usage Example

Check if the user has accepted analytics cookies:

```js
if (window.getCkyConsent) {
  const consent = getCkyConsent();

  if (consent.categories.analytics) {
    // Load analytics cookies
  } else {
    // User has not accepted analytics cookies
  }
}
```

Check if the user has completed an action on the banner:

```js
if (getCkyConsent().isUserActionCompleted) {
  // User has made a choice
} else {
  // Show banner to get user consent
}
```


---

## Structured Data

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Article",
      "headline": "Retrieving Consent Data Using getCkyConsent() API",
      "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "https://www.cookieyes.com/documentation/retrieving-consent-data-using-api-getckyconsent/"
      },
      "url": "https://www.cookieyes.com/documentation/retrieving-consent-data-using-api-getckyconsent/",
      "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 the use and implementation of getCkyConsent() API to easily access categorized cookie consent data from CookieYes banners.",
      "datePublished": "2024-01-22T09:59:10+00:00",
      "dateModified": "2025-07-08T07:25:51+00:00",
      "author": {
        "@type": "Person",
        "name": "CookieYes Doc Team"
      },
      "image": [
        "https://assets.cookieyes.com/cookieyes.png"
      ]
    },
    {
      "@type": "BreadcrumbList",
      "@id": "https://www.cookieyes.com/documentation/retrieving-consent-data-using-api-getckyconsent/#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": "Consent Management",
          "item": "https://www.cookieyes.com/category/documentation/features/consent-management/"
        },
        {
          "@type": "ListItem",
          "position": 5,
          "name": "Retrieving Consent Data Using getCkyConsent() API"
        }
      ]
    },
    {
      "@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/"
      }
    }
  ]
}
```
