1 St Party Listener

In order to stabilize 3rd Party Cookies on your website and mobile website, install our 1st Party Listener.

This script will avoid to loose user 's choice between two distinct session when the user uses a Browser like Safari that reject all 3rd Party Cookie.

How to install ?

Copy/past the following piece of JS in a new file and host it on your 1st Party domain.

listerner.min.js
var _acListener={version:"1.2.0",allowedKeys:["appConsent_uuid","appConsent_acn","appConsent_status"],isSupported:function(){try{return"localStorage"in window&&null!==window.localStorage}catch(a){return!1}},isValidData:function(a){var e=!1;return a&&a.version&&a.expire&&a.data&&a.version.trim()&&a.expire.trim()&&(e=!0),e},isOutdatedData:function(a){var e=new Date(a),t=new Date;return!(new Date(e)>new Date(t))},get:function(a){var e=localStorage.getItem(a);if(!(e&&e.length&&_acListener.allowedKeys.includes(a)))return null;try{var t=JSON.parse(e);return _acListener.isValidData(t)?_acListener.isOutdatedData(t.expire)?(_acListener.delete(a),null):t:null}catch(a){return null}},set:function(a,e){if(_acListener.allowedKeys.includes(a)){var t={version:e.version,expire:e.expire,data:e.data};if("appConsent_acn"===a){var n=_acListener.get("appConsent_acn");if(n&&n.data&&n.data[acLib.datas.versionID]&&n.data[acLib.datas.versionID].length)t.data[acLib.datas.versionID][acLib.datas.buildID]=e.data;else if(t.data=n&&n.data?n.data:{},t.data[acLib.datas.versionID]=t.data[acLib.datas.versionID]||{},acLib.datas.hasOwnProperty("usingPubvendors")&&acLib.datas.usingPubvendors&&acLib.datas.hasOwnProperty("pubVendorsHash")){var i=acLib.datas.buildID+"_"+acLib.datas.pubVendorsHash;t.data[acLib.datas.versionID][i]=e.data}else t.data[acLib.datas.versionID][acLib.datas.buildID]=e.data}return localStorage.setItem(a,JSON.stringify(t)),!0}return!1},delete:function(a){_acListener.allowedKeys.includes(a)&&localStorage.removeItem(a)},clear:function(){_acListener.allowedKeys.forEach(function(a){_acListener.delete(a)})}};window._acListener=_acListener;

Then add this script on your website:

<script src=https://www.mywebsite.com/cmp/listener.min.js></script>

This script must contain the exact path of your file, on your website. In this example, we named the JS file "listener.min.js, but you can name it with an other name if you want.

Take care of loading this script before loading the cmp snippet (no matter it's in sync or async/defer mode).

In case of doubt, load the 1st Party listener at the very begining of the Header section. As the script is fully controlled by you, there is no real risk to do so.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
<!-- ... -->
<script src=https://www.mywebsite.com/cmp/listener.min.js></script>
<script defer src="notice.js"></script>
</head>
<!-- ... -->
</html>

The Notice is able to detect if there is a 1st Party Listener loaded in the context. If not, the Notice will fall back to 3rd Party Cookie mode.

If you are using Tag commander or Google tag manager, this script must also be implemented directly on your website, NOT in the tag.