I used cookieconsent.insites.com to make the Cookie Consent button which after some adjustment the following code works.
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js"></script>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
"palette": {
"popup": {
"background": "#eaf7f7",
"text": "#5c7291"
},
"button": {
"background": "transparent",
"border": "#0965ed",
"text": "#0965ed"
}
},
"content": {
"dismiss": "Accept Cookies",
"href": "https://www.stevenredhead.com/Cookie.html"
}
})});
</script>
can be seen on my site https://www.stevenredhead.com
This code enables a cookie consent bar but only has two links; âaccept cookiesâ and âLearn Moreâ. GDPR regulations state that an opt-out or decline button is also added; I obtained the code from cookieconsent.insites.com but canât figure out where to add this;
"Disabling cookies should be done with the callback hook "(https://cookieconsent.insites.com/documentation/javascript-api/#hooks):
onInitialise: function (status) {
var type = this.options.type;
var didConsent = this.hasConsented();
if (type == 'opt-in' && didConsent) {
// enable cookies
}
if (type == 'opt-out' && !didConsent) {
// disable cookies
}
},
onStatusChange: function(status, chosenBefore) {
var type = this.options.type;
var didConsent = this.hasConsented();
if (type == 'opt-in' && didConsent) {
// enable cookies
}
if (type == 'opt-out' && !didConsent) {
// disable cookies
}
},
onRevokeChoice: function() {
var type = this.options.type;
if (type == 'opt-in') {
// disable cookies
}
if (type == 'opt-out') {
// enable cookies
}
},
There is also a link to callback hook mentioned above, https://cookieconsent.insites.com/documentation/javascript-api/#hooks
Any advice where to place the Disabling cookies code would be great. I tried quite a few placement options within the webpage but couldnât get success with my limited knowledge.
There also seems to be addition hooks at the #hooks link above, so I am unsure which of these to chose and where to place them; or if they are to be used to modify the decline text.
Any ideas would be most welcome.