Hi All,

This is probably me missing something. I have the module installed and it works fine, pop-up works fine. The problem is that adding the code http://drupal.org/node/1568590#comment-6033170 example by dagomar (obviously ignoring the php in the original as it is JS, and putting my own ID in)

if (Drupal.eu_cookie_compliance.hasAgreed()){
var _gaq = _gaq || [];_gaq.push(["_setAccount", "UA-xxxxxxx-xx"]);_gaq.push(["_trackPageview"]);(function() {var ga = document.createElement("script");ga.type = "text/javascript";ga.async = true;ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(ga, s);})();
}

It just doesn't work. I have tried various things, cleared the cache (browser and server), restarted varnish, httpd, etc. but nothing, analytics is not enabled. First, and probably dumb question, but I wan't to double check, where should the code be place?

The logical place to me was the theme template file.

If someone could confirm, I would be grateful.
Regards,
Nick

Comments

nickbits’s picture

I have just tried this on a fresh install of D6, only addition is the Zen theme. I have added this to the page.tpl file:

<script type="text/javascript">
alert("not yet");
if (Drupal.eu_cookie_compliance.hasAgreed()){
alert("Yes");
}
</script>

The if statement doesn't work. Reading the project page, I am assuming this should only work in modules, is there a way to make it work in a theme?

Would appreciate any feedback.
Regards,
Nick

Miszel’s picture

Hi Nick,

I suspect that your code runs before my code is loaded. Try the following and let me know if it works for you:

<script type="text/javascript">
$(document).ready(function() {
alert("not yet");
if (Drupal.eu_cookie_compliance.hasAgreed()){
alert("Yes");
}
});
</script>
nickbits’s picture

Status: Active » Closed (fixed)

Hi Marcin,

You are a star. Some times I wish I could kick myself. I should have thought of that, don't know why it didn't occur to me. Anyway, thanks again, much appreciated.

Regards,
Nick

Miszel’s picture

No problem. Thanks for using this module.

paardje’s picture