How to redirect after clicking on Allow & Block on Opt-in?

Some have a requirement where you want to redirect a user to a landing page once they complete the Web Push subscription.
We will share the required steps to be followed in that case.

Our typical installation code looks like this

<script> window._peq = window._peq || []; window._peq.push([“init”]); </script>
<script src=”https://clientcdn.pushengage.com/core/4xxxyoursitexx.js” async></script>

Instead of adding that please add the below code

1) Replace URL https://yourredirectpage.com with the page you want to redirect to

<script> window._peq = window._peq|| [];

window._peq.push([‘init’,{}.pe,function(res){

if(res.statuscode==1){ location = “https://yourredirectpage.com“; }

}

if(res.statuscode==2 || res.statuscode==3){

location = “https://yourredirectpage.com“;

}

}]);

</script>

<script src=”https://clientcdn.pushengage.com/core/4xxxyoursitexx.js” async>

So specifically, 1st line of code is replaced by the sample code snippet for redirection

<script> window._peq = window._peq || [];

window._peq.push([‘init’,{}.pe,function(res){

if(res.statuscode==1){ location = “https://yourredirectpage.com“;

}

if(res.statuscode==2 || res.statuscode==3){

location = “https://yourredirectpage.com“;

}

}]);

2nd line remains the same from your Settings > Site Settings > Installation Settings

<script src=”https://clientcdn.pushengage.com/core/4xxxyoursitexx.js” async>

</script>

That is it, folks; try it out & hope it works well.

If in case you run into any issues, please feel to contact us by clicking here. Our support team would be able to help you.

Still stuck? How can we help?
Last updated on September 22nd, 2022

Engage and Retain Visitors AfterThey’ve Left Your Website

Increase the value of every web visit with Push Notifications that are hard to miss.

  • Forever Free Plan
  • Easy Setup
  • 5 Star Support