To be able to use the hasAgreed() function, I relied on the observer pattern provided by the library
It can be done this way in order to declare a function which will be called after the cookie value has been loaded and the hasAgreed function works.
(beware, it is actually called twice, so you may want to protect your function against being called twice)
Drupal.eu_cookie_compliance("postStatusLoad", function postLoadHandle(scope,o) {
if (Drupal.eu_cookie_compliance.hasAgreed()){
//GOOGLE ANALYTICS CODE
}
else {
// DISABLE GOOGLE ANALYTICS CODE
}
});