How to redirect Shopify customer to specific page after login / logout / register
This article will guide you on how to redirect Shopify customers to a specific page after login, logout, and register in Shopify manually.
1. Redirect customers on new account creation
By default, the new customers are directed to the account page after registering a new account. Kindly follow the below steps to redirect the customer to a specific page when they register new account:
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click Actions > Edit code.
- In the Templates directory, click customers/register.liquid.
- Find the following line of code:1{% form 'create_customer' %}
On a new line below it, paste the following:
1<input type="hidden" name="return_to" value="/collections/all"> - For the value attribute in the line of code that you just pasted, replace
/collections/all
with the relative URL of the page that you want customers to see when they register new account. - Click Save
2. Redirect customer on login
When a customer visits your online store and logs in to their account, they will see a My Account page that shows their past orders and associated shipping and billing addresses. You can edit your theme so that customers are taken to a different page when they log in.
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click Actions > Edit code.
- In the Templates directory, click customers/login.liquid.
- Find the following line of code:1{% form 'customer_login' %}
On a new line below it, paste the following:
1<input type="hidden" name="checkout_url" value="/collections/all"> - For the value attribute in the line of code that you just pasted, replace
/collections/all
with the relative URL of the page that you want customers to see when they log in. - Click Save
3. Redirect customer on logout
By default, Shopify redirects the customers to the home page after logout. If you want to redirect the customer to show a specific page, there is no built-in way to do it. Here is a small script to achieve the same.
This script will work for all the logout links that you may have on the page.
1 2 3 4 5 6 7 8 9 10 | $(document).ready( function() { $('a[href^="/account/logout"]').on("click", function() { $.ajax( $(this).attr('href') ) .done(function() { // Here you will change the url to whatever page you want to redirect to window.location.href = "/collections/all"; }); return false; }); }); |
If you are technical, you may follow the above guides to do this manually. If you consider yourself non-technical, I’ve written an article to guide you to use a Shopify app to set up.
Wow really interesting article, Thanks for sharing this.
This is helpful if you want to redirect all users to the same page. If you want more dynamic redirect options, I would recommend the Customer Fields app.
You can conditionally redirect customers (after account creation) based on their form they fill out, or even based on their input. Here’s an article on conditional form redirects (http://help.heliumdev.com/en/articles/3541525-redirect-customers-after-form-submission)
You can even redirect to checkout and automatically add certain products to the customer’s cart (http://help.heliumdev.com/en/articles/3664703-how-to-use-form-redirects-for-order-conversion)
1. is no longer an option
2. I’m pretty sure is not working as well
@VladimirC , yes its not working.(Registration redirection).
Do you have any idea about redirect to specifiy page after registration
Try this app: https://apps.shopify.com/login-logout-redirect
Hi. This post was very helpful. Thank you. I was wondering if you know a way to bring up a different page upon login based on a customer tag. I need some customers to see the accounts page (default) and some to see the new login page.