Help Center

Listen to permission level changes from your own code

In order to react immediately to a change in the permission level settings of the visitor, custom JavaScript is needed on the page to subscribe to the onPermissionLevelChange event. The script below will reload the page to make sure conditional content will be correctly visible or hidden. A timeout is necessary to make sure other event listeners have finished before reloading the page.

<script type="text/javascript">
    var onPermissionLevelChangeHandler = function(event, context)  {
        try {
            // Reload page so that any personalized content will become available.
            // Delay the reload by 500ms to make sure other event 
listeners have finished setTimeout(function() { location.reload(true); }, 500); } catch(err) { } }; if (window.blueConicClient) { // BlueConic client is loaded, subscribe window.blueConicClient.event.subscribe("onPermissionLevelChange",
this, onPermissionChangeHandler); } else { // BlueConic client is not yet loaded, prepare subscription for when it loads window.bcSubscriptions = window.bcSubscriptions || []; window.bcSubscriptions.push(["onPermissionLevelChange",
onPermissionChangeHandler]); } </script>


Was this article helpful?
0 out of 0 found this helpful