This time I will share jQuery Plugin and tutorial about GDPR and Cookie Consent Modal for Google Analytics – jQuery CookieKit, hope it will help you in programming stack.
CookieKit is an easy-to-use jQuery plugin that displays a GDPR and Cookie consent modal when users first visit your site and dynamically inserts Google Analytics tag into the document when they accept the data collection policy.
More about GDPR:
How to use it:
1. Load the jquery.cookiekit.js
JavaScript library after jQuery.
1 |
< script src = "/path/to/cdn/jquery.min.js" ></ script > |
2 |
< script src = "/path/to/jquery.cookiekit.js" ></ script > |
2. Initialize the CookieKit and insert your own Google Analytics Tracking ID. That’s it.
1 |
$(document).cookieKit({ |
3. Change the language of the GDPR and Cookie Consent Modal. Default: ‘fr’.
1 |
$(document).cookieKit({ |
4. Customize the appearance of the GDPR and Cookie Consent Modal.
01 |
$(document).cookieKit({ |
05 |
backgroundColor: '#e9e9e9' |
08 |
acceptColor: '#0a9919' , |
09 |
acceptColorHover: '#076212' , |
10 |
refuseColor: '#8a0a0a' , |
11 |
refuseColorHover: '#550505' , |
5. Assign a unique ID to the modal. Default: empty.
1 |
$(document).cookieKit({ |
6. Set the cookie name, path, and expiration date.
1 |
$(document).cookieKit({ |