How to redirect customers after login or registration in Shopify

Redirect your customers to sections of interest or promotional content on other pages after they log-in or sign-up
Froonze
November 15, 2023

A redirect after login is a useful tool that merchants and e-shops can use to improve the user experience and save time to returning customers.

By default, Shopify sends users to their account page after they sign up or log in. However, you can modify this behavior to send users to any page on your site. This can be used to strategically guide users towards desired actions and relevant content. Like a specific product page or category, a thank you page, a survey or feedback form. Or a specific landing page, a special offer or promotion, a blog post or article, a social media page. Or featured products, recommended items, that will increase cross-selling or upselling opportunities.

How to redirect customers after login or registration in Shopify

To make the native login and register forms in Shopify redirect to a desired page, you can add a hidden input to the form. To do so you need to locate the forms in the Theme HTML code and add the code of the input.

  1. Go to your Shopify admin and navigate to Online Store > Themes. Find the theme you want to edit and click on the Three points icon > Edit code.
  2. In the Theme Editor, search for the word "login". This will bring up the template that contains the login form (usually login.liquid or main-login.liquid). Open it.
  3. Inside the login template, find the following code: form 'customer_login'
  4. One line below add the input code that you see below. You can replace the value between double quotes for any other page on your site.

<input name="return_to" type="hidden" value="/collections/all">

  1. Now find the template containing the registration form. It's usually register.liquid or main-register.liquid
  2. Inside the register template, find the following code: form 'create_customer'
  3. And one line below paste the same input code that we mentioned above. You can use a different redirection page.
  4. Save and Test

No code solution

If you are not familiar with code or prefer a no-code solution, you should try our Custom Forms plugin.

This plugin allows you to create custom registration and profile forms and collect additional information from your customers. It also allows setting up redirects to specific pages after registration.. Learn more about its features here: Custom Forms: collect all data you need from your customers

Script Alternative

A perhaps simpler, but less clean solution, would be to add a general script to the main layout that finds and modifies the forms.

  1. Go to your Shopify admin and navigate to Online Store > Themes. Find the theme you want to edit and click on the Three points icon > Edit code.
  2. In the Theme Editor, search for theme.liquid. This will bring up the main layout. Open it.
  3. Inside the layout, find the end of the body: </body>
  4. One line above, paste the script below. You can replace the REDIRECT_PATH value but in this case it'll be the same path after both log-in and sign-up. Save and Test:

<script> document.addEventListener('DOMContentLoaded', function() { var REDIRECT_PATH = '/collections/all'; var selector = '#create_customer, #customer_login', $signForm = document.querySelectorAll(selector)[0]; if ($signForm) { $redirect = document.createElement('input'); $redirect.setAttribute('name', 'return_to'); $redirect.setAttribute('type', 'hidden'); $redirect.value = REDIRECT_PATH; $signForm.appendChild($redirect); } },false); </script>

Summary Questions

What is a "redirect after login" ?

A "redirect after login" is a useful tool that allows merchants and e-shops to send users to a specific page on their website after they sign up or log in. This feature enhances the user experience, saves time for returning customers. And strategically guides users towards desired actions and relevant content. Such as product pages, special offers, surveys, and more.

How can merchants modify the default behavior of Shopify's login and registration process?

By default, Shopify sends users to their account page after they sign up or log in. Merchants can modify the default behavior of Shopify's login and registration process by adding a hidden input to the form. This allows them to redirect users to any page on their site after login or registration.

What do I need to enable and modify the log-in and sign-up forms in Shopify?

You need to enable Customer Accounts in Shopify, to create and manage your customers' accounts. And you also need to choose the option for Classic Customer Accounts to be able to modify the login and register templates,

How does "redirect after login" benefit merchants and e-shops?

This feature offers several key benefits. It saves time for returning customers, as they are immediately taken to the relevant section they intend to access. It also increases engagement by presenting users with tailored content or exclusive deals upon login. This can boost customer loyalty and encourage repeat purchases. The feature enables e-shops to showcase new products, discounts, or other relevant information. maximizing the impact of their communication efforts.

Is there a no-code solution available for redirecting users after registration on Shopify?

Yes, there are several apps that can apply the feature without the need of you adding code. Ours is called Custom Forms. This plugin allows you to create custom registration and profile forms. These forms collect additional data from your customers using personalized fields. It also allows setting up redirects to specific pages after registration.

Redirect user to previous page after login shopify

If you want to redirect users to a previous page you can use this code that includes a 'referrer' variable (instead of just the input)

<input id="return_to" name="return_to" type="hidden" value=""> <script> document.addEventListener('DOMContentLoaded', function() { var returnRef = document.referrer; document.querySelector('#return_to').value = returnRef; },false); </script>

Froonze Customer Accounts Concierge
Get the app today
Turn the account page into a beautiful portal with
Froonze Customer Accounts Concierge
  • 250+