I was contacted by a reader who had made some clever customisations to Cookie Notice to avoid need to reload his psychology site. He had one remaining issue: “Users can navigate normally without closing the popup but cookies are not created.

i.e. If a visitor navigates your site without ever clicking the cookie bar button then your cookie blocked scripts will never be loaded. N.B. this is NOT an issue for non-EU visitors if you are using the CCA plugin.

According to itgovernance.eu (under heading “Achieving compliance”): “soft opt in” by on-site navigation is permissible under GDPR. No doubt CN will eventually cover this; but in the mean time we can create our own simple plugin solution to add automatic acceptance by on-site navigation:

<?php
/*
Plugin Name: my site customization stuff
Description: add my WordPress customizations
Version: 1.0
*/
add_action( 'wp_head', 'my_cn_soft_opt_in' );
function my_cn_soft_opt_in() {
?>
<script>
window.onbeforeunload = function() {
  if ( ! ( /(^|;)\s*cookie_notice_accepted=/.test(document.cookie)) ) {
    document.cookie = "cn-has-visited=true; max-age=" + 60 * 3 +"; path=/";
  }
};

if (  /(^|;)\s*cn-has-visited=/.test(document.cookie))  {
  document.cookie = "cookie_notice_accepted=true; max-age=" + 3600*24*365 + "; path=/";
  document.cookie = "cn-has-visited=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
  // optionally reload page
}
<!-- you can also add other JS to HTML head here -->
</script>
<?php
}
<!-- you can insert other custom code for site here -->
?>

Explanation: If Cookie Notice cookie has NOT been set then, on page exit, a temporary “has visited” cookie is created. If your visitor is exiting from this page to another on your site; then the “has visited” cookie identifies this – and your visitor is automatically opted-in to accepting cookies.

If you have opted for “reload” in your Cookie Notice settings then you may wish to replace the yellow highlighted reload comment with window.location.reload( true );.

You should probably alter your cookie bar text to indicate on-site navigation is treated as acceptance.