The following snippet lets you redirect users to a plan-specific page after they sign up. It will override the value in Auth > Sign up and Login >Sign up settings > Post Signup URL.
Depending on your need, you might be looking for:
👉 Redirect to a plan-specific page post login, aka when a user logs in
👉 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.
The script will 1. map your plan's unique IDs with their respective pages, and 2. redirect the user to the correct page after they log in.
Remember to substitute lines in Step 1 with your plan UIDs and paths.
<!-- 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>
// 1. Map your plan UIDs with their respective plan specific pages
const plansToLandingPage = {
// Create one line per plan (as many as you’d like),
// replacing the examples with your plan UIDs and plan paths
['planUidA']: '/path-to-plan-A-page',
['planUidB']: '/path-to-plan-B-page',
['L9PozjQJ']: '/path-to-plan-L9PozjQJ-page',
};
// 2. Redirect the user to the correct landing page after they sign up
Outseta.on('signup', (account) => {
// Grab the user’s plan uid
const planUid = account.CurrentSubscription.Plan.Uid;
// Find the plan's redirect url
const redirectUrl = plansToLandingPage[planUid];
// Redirect to the landing page configured for the plan,
// or let Outseta do its default thing if none is configured
if (redirectUrl) {
window.location.href = redirectUrl;
return false;
}
});
</script>
<!-- ✨ Custom Code Snippet End ✨ -->
To find your plan UIDs, go to Billing > Plans, then the name of any given plan. The UID is an alphanumeric value in the URL structure of the page (see screenshot below).