Skip to content

grt107/grt-cookie-consent

Repository files navigation

GRT Cookie Consent - jQuery Plugin

Simple and lightweight jQuery plugin used for Cookie Consent on GDPR Law.

This plugin is highly customizable, you can change background, text and button colors without modifying the CSS, to better fit to your website color palette. It also comes optimized for mobile devices.

You can check the demo here: grt107.github.io/grt-cookie-consent/

Screenshot:

Alt text

How to use the plugin in your website:

1- Include the plugin stylesheet file grt-cookie-consent.css inside your <head> tag

<link rel="stylesheet" href="grt-cookie-consent.css">

2- Include the plugin javascript file grt-cookie-consent.js inside the <body> tag and after jquery.min.js

<script src="grt-cookie-consent.js"></script>

3- Add the following code inside your document body and change the text content and button name:

  <div class="grt-cookie"> 
   <div class="grt-cookies-msg">
    <p> We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you accept and understand our <a href="">Privacy Policy</a>, and our <a href="">Terms of Service</a>.</p>
   </div> 
   <span class="grt-cookie-button">Accept</span>
  </div>

4- Initialize the plugin with default values at the end of all javascript files using the code below (after jquery.min.js and grt-cookie-consent.js)

  <script> $(".grt-cookie").grtCookie(); </script>

Advanced Options

You can customize plugin colors and cookie duration by using the following code:

  <script>
  $(".grt-cookie").grtCookie({
  	// Main text and background color
  	textcolor: "#333",
  	background: "#fff",
  	// Button colors
  	buttonbackground: "#c40b14",
  	buttontextcolor: "#fff",
  	// Duration in days
  	duration: 365,
  });
  </script>