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

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

Our typical installation code likes 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 essentially 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 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 you need help, you can reach out & email us at care@pushengage.com.

Still stuck? How can we help?
Last updated on March 4th, 2021

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