How do I add a third-party service to Zoho Sites Cookie Bar?

How do I add a third-party service to Zoho Sites Cookie Bar?

Create a third party cookie configuration JSON array to be included in the default cookie configuration JSON to display the third party cookies in the Cookie consent banner.

This configuration can be added to the header/footer code.

 

Code for adding the third party cookie configuration JSON to the default configuration JSON:

var thirdparty_cookies={

zc_cookies:[{

"group_id": "<category_identifier>",

"zs_name":"<service_name>",

"zs_desc":"<service_description>",

"zc_detail":[{

"c_name": "<cookie_name>",

"c_type" : "<cookie_type>",

"c_purpose" : "<cookie_purpose>",

"c_expiry" : "<cookie_expiry_duration>"

},

"group_id": "<category_identifier>",

"zs_name":"<service_name>",

"zs_desc":"<service_description>",

"zc_detail":[{

"c_name": "<cookie_name>",

"c_type" : "<cookie_type>",

"c_purpose" : "<cookie_purpose>",

"c_expiry" : "<cookie_expiry_duration>"

}]

}]

}

window._zcBan.set_config(thirdparty_cookies);


category_identifier - "essential" or "functional" or "analytics".
c_type - "server" or "client"
c_expiry - "1 day". It could be 1 day, 30 days, 2 Months etc. 
 

 

Method to handle consent in Zoho Sites cookie bar

 

Event listeners should be added by the site owner to accept and decline events. These two event listeners are created in the document object and will be triggered for accept and decline respectively.

 

In the below sample code, two listeners are added to the document object.

  • When the user accepts cookies, the acceptConsent event is triggered with the categories accepted.

  • When the user declines cookies, the declineConsent event is triggered.

  • It is the responsibility of the site owner to handle the respective third party cookies based on the event listeners for accept and decline events.

Here is the script to handle consent in headers and footers:

 

document.addEventListener('acceptConsent', (e) => {

    // Handle for accept event

});

 

document.addEventListener('declineConsent', (e) => {

    // Handle for decline event

});


The event 'e' will have the following details in JSON object format.
{
      "zc_optOut": true,
      "essential": true,
      "functional": true,
      "analytics": true,
      "event_origin": "click"
}

"zc_optOut" - true in case of accept and false in case of decline
"essential", "functional", "analytics"  - true if accepted, false otherwise.
"event_origin" - "click" (The user has provided consent) or "onload" (The provided consent will be triggered during onload)