If you want to make use of the very excellent iUbenda.com for your cookie/privacy solution, and want to be fully GDPR compliant, but you don’t want to upgrade to one of iUbenda’s higher tier billing levels, then you’ll need to implement your own system to keep a database/record of consent.
In the iUbenda control panel for your website, in the EDIT menu to “Configure your Privacy Controls and Cookie Solution” is an ‘Advanced’ section where callbacks can be specified. These need to be short JavaScript snippets which will be called/triggered in the case of each specified event.
To keep things simple, for my own implementation I added the same code to each of the callbacks I was interested in:
function(preference) { uLog(preference); }
And then, just above the embedded iUbenda JavaScript on every page of the target website I defined the function uLog as follows:
<script type="text/javascript">
function uLog(preference)
{
// Call default endpoint to record this
var json = JSON.stringify(preference);
//console.log(json);
$.ajax("/iubenda.php?preference=" + encodeURIComponent(json));
}
</script>
This function is then called every time the webhook I added the callback code to is triggered. All this function does is use jQuery (required also for this to work) to make an Ajax call to some PHP (or any other database connected) code which stores the preference data (and the user’s IP address and user agent – no other relevant information is available I don’t believe). Here’s some code for the PHP Ajax call target:
<?php
$ra = $_SERVER['REMOTE_ADDR'];
$ua = $_SERVER['HTTP_USER_AGENT'];
$pf = json_decode($_GET['preference']);
// You can now store the above in a database/file etc.
?>
Add some code after the comment and you’re now keeping a recording of consent preferences without having to upgrade your iUbenda account 🙂