The following snippet lets you redirect users to a page when they change their plan in the profile embed.
Depending on your need, you might be looking for:
👉 Redirect to a plan-specific page post signup, ie. before they create a password
👉 Redirect to a plan-specific page post first-time login, aka onboarding
👉 Redirect the user back to a protected content page they were attempting to access after login
The snippet
Add the provided custom code snippet (found between <!-- ✨ Custom Code Snippet Start ✨ -->
and <!-- ✨ Custom Code Snippet End ✨ -->
) to the head of your site below the Outseta script, which should already be in your site's head tag.
After completing a plan change in the Profile embed, the script will redirect the user to the page configured. Change the value /success
to configure the path for the page you'd like to redirect to.
<!-- Outseta Script Options -->
<script>
var o_options = {
domain: '[your-domain].outseta.com',
};
</script>
<!-- Outseta Script (doing all the magic) -->
<script src="https://cdn.outseta.com/outseta.min.js" data-options="o_options"></script>
<!-- ✨ Custom Code Snippet Start ✨ -->
<script>
// Redirect to a path on subscription update events
Outseta.on("subscription.update", (data) => {
// ❗ Change /success to the path for the page you'd like to redirect to.
const redirectPath = "/success";
const url = new URL(redirectPath, window.origin);
window.location = url.href;
});
</script>
<!-- ✨ Custom Code Snippet End ✨ -->