Hi,
i wanted to share a script to set a cookie, so an interaction would show only when cookie criteria is met, e.g: once a day/week etc… (you can change it as you see fit). i’m using js-cookie lib for that.
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.0/js.cookie.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
// get a reference to the loading wrapper
const popUp = document.querySelector('CLASS-NAME-OF-THE-ELEMENT-U-ANIMATE');
// get the 'seenAnimation' cookie and store in a seenAnimation variable
const seenAnimation = Cookies.get('seenAnimation');
// if the 'seenAnimation' cookie is undefined
if(!seenAnimation){
// set the 'seenAnimation' cookie
Cookies.set('seenAnimation', 1, { expires: 1 });
}
else{
// else if the 'seenAnimation' cookie exists
// the user has already seen the animation
// and so
// hide the loading-wrapper
popUp.style.display = "none";
popUp.style.opacity = "0";
}
});
</script>
in this script i’m hiding the loading wrapper if cookie exist by applying these styles:
popUp.style.display = “none”;
popUp.style.opacity = “0”;