Looking for a way to redirect users to the specific URL if they declined cookies? We’ve got a perfect solution for this:
const DECLINE_LINK = 'https://example.com';
const bar = document.querySelector('[class*="eapps-cookie-consent"]');
bar?.addEventListener('click', (e) => {
if (e.target.closest('.eapp-cookie-consent-actions-decline')) {
window.open(DECLINE_LINK, '_self');
}
});
Replace the example link in the 1st line with the needed URL and add the resulted code to the Custom JS field on the Style tab of your Cookie Consent widget’s settings.
Note: Custom JS doesn’t function in the preview mode, so you can check the result right on your website or through the Share Link
Guys, was this solution helpful? Let us know in the comments ![]()