Documentation Center

Triggering Javascript After Prompt Approval/Denial

With Aimtell's Javascript API it's easy to trigger some custom javascript after your website visitor either approves or denies your request for push notifications.

With Aimtell's Javascript API it's easy to trigger some custom javascript after your website visitor either approves or denies your request for push notifications.

Scenario 1 - Visitor approves the subscription prompt.

If a visitor approves the push notification prompt, the function _aimtellPermissionGranted() is called. So, in order to execute some javascript after the visitor grants permissions, set up something like this on your website:

<script>
function _aimtellPermissionGranted(){
console.log("Wohoo, visitor subscribed to push!");
}
</script>

 

Scenario 2 - Visitor denies the subscription prompt.

If a visitor denies the push notification prompt, the function _aimtellPermissionDenied() is called. So, in order to execute some javascript after the visitor denies permissions, set up something like this on your website:

<script>
function _aimtellPermissionDenied(){
console.log("Darn, visitor didn't subscribe to our push");
}
</script>