So I have google analytics module and eu-cookie-compliance module, both working fine. Now I'm trying to disable google analytics if user didn't give permission for cookies on eu-cokie-compliance. I know that cookie module has javascript function
Drupal.eu_cookie_compliance.hasAgreed()
But I have to check that from php code in google analytics. So when page first load google analytics will be disabled.
Any ideas how to make it work?
<?php
$cookie=$_COOKIE['cookie-agreed-sl'];
if($cookie==1 || $cookie==2)return true;
else return false;
?>
So i added that code to google analytics code but it always returnss false so google analytics cookie is newer set. I tried that code in some php file and there it works. How to fix it?