setConsentGiven is not setting the cookie

Hi, I am having an issue where the tracking cookie is not being set. It is on a Drupal site. I have the following code and cannot figure out why it is not working.

_paq.push(['requireConsent']);

document.addEventListener('click', function (event) {
	if (!event.target.matches('.agree-button')) return;
	event.preventDefault();
       _paq.push(['setConsentGiven']);
}, false);

var cookieValue = document.cookie.replace(/(?:(?:^|.*;\s*)cookie-agreed\s*\=\s*([^;]*).*$)|^.*$/, "$1");

if (cookieValue === "2") {
     _paq.push(['setConsentGiven']);
};

Thanks for the help.

If you provide me the URL to your site, I can try to take a look.