The Mobile Galaxy The New Mobile Era Has Come | Mobile – A Time To Remember

26Apr/120

EU Cookie Directive Solutions

Massive thanks to Greg Rouchotas from CivicUK.

What you need for EU LAW COMPLIANCE:

  • Access to the template files that make your website work or if your on Drupal 7 or WordPress  you get easy install mods! (you can ignore the rest of this guide)
  • Jquery 1.4.4 or above called into your templates (Drupal 6 users see this fix, Method 3 or 4 patch your jquery mod and upload latest jquery)
  • CookieControl-3.0.min.js from the CivicUK website (DirectLink)
For Piwik – NO COOKIE Tracking
  • Access to deploy a new MYSQL Database for Piwik to use
  • A different set of code to integrate CookieControl with GA and Piwik (See bottom of  this guide)

Then all you need to do is paste the below code  before your </head> of your websites template depending on your templates this may be your header template file or at the top of your Index file.

<script type=”text/javascript”>
function ccAddAnalytics(){
$.getScript(‘http://www.google-analytics.com/ga.js’, function() {
var GATracker = _gat._createTracker(‘YOUR GA TRACKING CODE UA-00000‘);
GATracker._trackPageview();
} );

</script>

<script src=”http://www.geoplugin.net/javascript.gp” type=”text/javascript”></script>
<script src=”http://pathtoCookieControlScript/cookieControl-3.0.min.js” type=”text/javascript”></script>
<script type=”text/javascript”>//<![CDATA[
cookieControl({
text:'<p>This site uses cookies to store information on your computer. Some of these cookies are essential to make our site work and others help us to improve by giving us some insight into how the site is being used.</p><p>By using our site you accept the terms of our <a href="http://www.YOURPRIVACYURL">Privacy Policy</a>.</p>',
position:'right', // or right
shape:'diamond', // or diamond
startOpen:true,
autoHide:60000,
onAccept:function(){ccAddAnalytics()},
onCookiesAllowed:function(){ccAddAnalytics()},
onCookiesNotAllowed:function(){
},
countries:'United Kingdom' // Or supply a list ['United Kingdom', 'Greece']
});
//]]>
</script>

Piwik Cookie-less Tracking

I’m not going to run through installing Piwik as it’s well covered on their website, in all it took me 15 minutes to install and configure it onto our servers.

One you have it on your server you need to use the below code to not only call Google Analytic’s but also Piwik, just as with the basic code above this needs to go before the </head>

<script type=”text/javascript”>
function ccAddAnalytics(){
$.getScript(‘http://www.google-analytics.com/ga.js’, function() {
var GATracker = _gat._createTracker(‘YOUR GA TRACKING CODE UA-00000”);
GATracker._trackPageview();
} );

$.getScript(‘http://LOCATION OF PIWIK ON YOUR SERVER/piwik/piwik.js’, function(){
var pkBaseURL = ((“https:” == document.location.protocol) ? “http://LOCATION OF PIWIK ON YOUR SERVER/piwik” : “http://LOCATION OF PIWIK ON YOUR SERVER/piwik”);
var piwikTracker = Piwik.getTracker(pkBaseURL + “piwik.php”, 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
});

};

</script>

<script src=”http://www.geoplugin.net/javascript.gp” type=”text/javascript”></script>
<script src=”http://pathtoCookieControlScript/cookieControl-3.0.min.js” type=”text/javascript”></script>
<script type=”text/javascript”>//<![CDATA[
cookieControl({
text:'<p>This site uses cookies to store information on your computer. Some of these cookies are essential to make our site work and others help us to improve by giving us some insight into how the site is being used.</p><p>By using our site you accept the terms of our <a href="http://http://www.YOURPRIVACYURL">Privacy Policy</a>.</p>',
position:'right', // or right
shape:'diamond', // or diamond
startOpen:true,
autoHide:60000,
onAccept:function(){ccAddAnalytics()},
onCookiesAllowed:function(){ccAddAnalytics()},
onCookiesNotAllowed:function(){
var doc_title=document.title;
var doc_ref=document.referrer;
$('body').append("<img src=\"http://LOCATION OF PIWIK ON YOUR SERVER/piwik/piwik.php?idsite=1&amp;rec=1&amp;action_name="+doc_title+"&amp;urlref="+doc_ref+"\" style=\"border:0\" />");
},
countries:'United Kingdom' // Or supply a list ['United Kingdom', 'Greece']
});
//]]>
</script>

Now clear your cache and reload the site, head over to your Piwik login and you should see data from all your users who don’t accept Cookies, check in your Google Analytic’s Real Time Results when you click the Accept button and you should see yourself appear in Real Time Results within a few seconds.

 

Other options:

1. Wolf Software provide a number of solutions to assist with compliance. Demos can be located at:

http://cookies.dev.wolf-software.com (Simple one line GA drop in solution)

http://jpecr.dev.wolf-software.com (a universal solution with multiple configuration options)

2. cookie-warning

3. UK & European Cookie Law Solution (Free Script) 

Resource

1. Geoplugin--Get country by IP

2. GeoLite Country-Country Information  Database

3. Preventing Google Analytics Cookies

<script type="text/javascript">
if (_cookieOK.accepted){
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-222592-4']);
  _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);
  })();
}
</script>
The relevant changes to the stock script are highlighted in red. At the moment the _cookieOK variable only has the accepted property, but we may well add more.

Demo & sample

1. ba.com

2. bt.com(has implemented quite a comprehensive response to the cookie law today, if you’re in need of some more inspiration…)

3. EU cookie law: three approaches to compliance(Modal dialogue,Status bar,Warning bar)

4. http://cookieok.eu/

 

Share
Filed under: iPhone No Comments