Getting started on your implementation

Collecting & retrieving your visitor’s cookie preference
  • Visitor's cookie preference is collected via the consent banner installed on your website

  • You can retrieve the cookie preferences (Cookies your visitors consented to) via:

1. JS Callback

These callback functions will be called in different situations. You will have access to the visitor UUID as well as the accepted list of cookies/categories via these callback functions. It’s your responsibility to implement these functions.

getCookieWhitelistByTermly(data)

When is this called?

  • This callback method is triggered automatically each time your visitor refreshes the web page or has navigated to another page on your website (Unless it’s a SPA).

What should I do here

  • Save/Update the whitelist (data.cookies,data.categories) in your front end code if you need to refer to it elsewhere. (e.g.: To set cookie from your frontend code based on what’s in the whitelist.)

  • If your website visitor has not yet given consent, you will not be able to get the UUID (data.uuid) here. However, if an UUID is present (i.e.: not null), this means your website visitor has already given consent. You may wish to store the UUID for later use (e.g.: For calling the Termly RESTful API).

Sample responese data of getCookieWhiteListByTermly
{
cookies:
[
{ 'name': 'cookie_name', 'provider': 'termly.io', 'type': 'http_cookie' },
{ 'name': 'cookie_name', 'provider': 'termly.io', 'type': 'http_cookie' }
]
categories: ['essential'],
uuid: '104697b6-5b10-4aa3-8f8e-52ac2af5ef37'
}

getUpdatedCookieWhitelistByTermly(data)

When is this called?

  • This callback method is triggered when your visitor gives consent to the use of cookies via the consent banner or through the cookie preference center installed on your website.

What should I do here?

  • Save the whitelist (data.cookies,data.categories ) in your front end code if need to refer to it elsewhere. (e.g.:you need to set cookie from your frontend code based on what’s in the whitelist.)

  • You will get the UUID (data.uuid) here. You may wish to store the UUID for later use (e.g.: For calling the Termly RESTful API).

Sample response data of getUpdateCookieWhitelistByTermly
{
cookies:
[
{ 'name': 'cookie_name', 'provider': 'termly.io', 'type': 'http_cookie' },
{ 'name': 'cookie_name', 'provider': 'termly.io', 'type': 'http_cookie' }
]
categories: ['essential'],
uuid: '104697b6-5b10-4aa3-8f8e-52ac2af5ef37'
}

2. Termly RESTful API

If your website is setting cookies from the backend, then you will not have access to the JS Callbacks and will need to use this API to retrieve the list of cookies/categories (Cookie whitelist) your visitor has consented to.