Configuring Cookie Control

Cookies

Image sourced from Vegan Feast Catering on Flickr

Last week I went through how to install Cookie Control on various content management systems and hand coded sites. I did not deal with the configuration of the plugin so this week I have writen an article explaining how to configure the Cookie Control plugin. If you are using Wordpress, Drupal or Magento, you should be able to configure Cookie Control easily from the admin interface. Just check last weeks article for how to install.

I am not going to cover every parameter, as some are more complex, and will rarely be required, but it should give you enough to get the plugin implemented in 99  % of cases.

Assuming you are hand coding, first of all you need to include some necessary Javascript files to get Cookie Control working.

<script src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
<script src="/PATH_TO_COOKIE_CONTROL/cookieControl-4.1.min.js" type="text/javascript"></script>

Now you need to call the cookieControl function, and pass a list of parameters to it:

cookieControl({your parameters go here});

Visual Configuration

Some aesthetic qualities of cookie control can be configured. 

  • shape: You may choose between the diamond or triangle Cookie Control icon. 
  • position: You can choose whether the icon floats on the left or right. 
  • theme: You can choose between the light and dark Cookie Control theme. 

The Copy

You can control the text that Cookie Control uses to briefly describe its function and to provide further details on what your cookies are used for.

  • introText: Some punchy copy to introduce the role of cookies on your site. 
  • fullText: Used to describe in general what your cookies are used for. 

Is Your Website Compliant?

EU legislation requires that you tell the users of your website what cookies you are storing on their computer. If you have user logins, use any kind of analytics or advertise using online advertising networks on your site, chances are you are using cookies. Click below to find out how we can help you comply:

Enquire Now >

Other Important Settings

There are a few more relevant parameters to discuss.

  • countries: A comma-separated list of countries to display the Cookie Control plugin for. (takes a string or array.)
  • startOpen: Determines whether cookie control is open by default. This is the safer option regarding compliance. (takes true or false)
  • subdomains: Does Cookie Control apps to all sub-domains or is each Cookie Control instance on each sub-domain separate? (takes true or false)

Other Information

  • You should include a link to your cookie/privacy policy from the ‘Additional Text’ you provide.
  • Google Analytics can be integrated with cookie control by moving your GA code into the function ccAddAnalytics(), and then setting the parameters onAccept:function(){ccAddAnalytics()} and onCookiesAllowed:function(){ccAddAnalytics()} and then adding the ccAddAnalytics() function from the code below.
  • By modifying the Google Analytics code, you can deal with any other cookies you might need to on an individual basis. 

I included some example code below, I thought it might help to clarify things. 

<script src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
<script src="/PATH_TO_COOKIE_CONTROL/cookieControl-4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">//<![CDATA[
cookieControl({
introText:'<p>This site uses some unobtrusive cookies to store information on your computer.</p>',
fullText:'<p>Some cookies on this site are essential, and the site won\'t work as expected without them. These cookies are set when you submit a form, login or interact with the site by doing something that goes beyond clicking on simple links.</p><p>We also use some non-essential cookies to anonymously track visitors or enhance your experience of the site. If you\'re not happy with this, we won\'t set these cookies but some nice features of the site may be unavailable.</p><p>By using our site you accept the terms of our <a href="location_of_your_privacy_policy">Privacy Policy</a>.</p>',
position:'left', // left or right
shape:'diamond', // triangle or diamond
theme:'light', // light or dark
startOpen:true,
autoHide:6000,
subdomains:true,
onAccept:function(){ccAddAnalytics()},
onReady:function(){},
onCookiesAllowed:function(){ccAddAnalytics()},
onCookiesNotAllowed:function(){},
countries:'United Kingdom' // Or supply a list ['United Kingdom', 'Greece']
});
function ccAddAnalytics() {
jQuery.getScript("http://www.google-analytics.com/ga.js", function() {
var GATracker = _gat._createTracker('GA_TRACKER_CODE');
GATracker._trackPageview();
});
}
//]]>
</script>

Development