How to change customer after-login redirect destination
A guide to customizing where customers are redirected after logging into your Shopify store.
What is the after-login redirect?
The after-login redirect determines which page customers see immediately after successfully logging into your store. By default, Shopify redirects customers to their account page, but you can customize this to redirect them to your homepage, a specific product page, or any other page that better serves your business goals.

Why you might want to change the redirect
Redirecting customers to different pages after login can improve their shopping experience and drive business results. Sending customers to your homepage keeps them engaged with your latest products and promotions, while redirecting to a specific collection page can guide them toward relevant products based on their interests.
Some merchants prefer to redirect VIP customers to exclusive product pages, while others want to send customers directly back to where they were shopping before logging. The right choice depends on your store's strategy and customer journey design.
Method 1: Using hidden input field (Recommended)
This is the most straightforward and reliable method for changing the after-login redirect.
1. Access your theme code editor
From your Shopify admin, go to Online Store → Themes
Find your current theme and click Actions → Edit code
You'll be taken to the theme code editor
2. Locate the login form file
Look for the login form in one of these common locations:
sections/main-login.liquid (most common)
templates/customers/login.liquid
sections/customer-login.liquid
snippets/customer-login.liquid
3. Find the customer login form
In the login file, look for the customer login form that looks like this:
{%- form 'customer_login', novalidate: 'novalidate' -%}
<!-- form fields here -->
{%- endform -%}
4. Add the redirect code
Inside the form tag (before the {%- endform -%}
line), add this hidden input field:
<input type="hidden" name="checkout_url" value="{{ routes.root_url }}">
5. Complete example
Your form should look like this after adding the redirect code:
{%- form 'customer_login', novalidate: 'novalidate' -%}
<div class="field">
<input type="email" name="customer[email]" id="CustomerEmail" autocomplete="email">
<label for="CustomerEmail">Email</label>
</div>
<div class="field">
<input type="password" name="customer[password]" id="CustomerPassword" autocomplete="current-password">
<label for="CustomerPassword">Password</label>
</div>
<!-- Add this line to redirect to homepage -->
<input type="hidden" name="checkout_url" value="{{ routes.root_url }}">
<button type="submit" class="button">Sign in</button>
{%- endform -%}
6. Save your changes
Click Save to apply the changes to your theme.
Method 2: Dynamic redirects with URL parameters
For more advanced control, you can create dynamic redirects based on URL parameters.
1. Modify the login form
Add this code inside your login form:
{%- assign return_url = request.headers['Referer'] | default: routes.root_url -%}
{%- if request.params.return_url -%}
{%- assign return_url = request.params.return_url -%}
{%- endif -%}
<input type="hidden" name="checkout_url" value="{{ return_url }}">
2. Create custom login links
You can now create login links that redirect to specific pages:
<!-- Redirect to homepage after login -->
<a href="{{ routes.account_login_url }}?return_url={{ routes.root_url | url_encode }}">Login</a>
<!-- Redirect to shop page after login -->
<a href="{{ routes.account_login_url }}?return_url={{ routes.collections_url | url_encode }}">Login</a>
<!-- Redirect to current page after login -->
<a href="{{ routes.account_login_url }}?return_url={{ request.url | url_encode }}">Login</a>
Common redirect destinations
Here are the most popular redirect destinations and their Liquid code:
Homepage
{{ routes.root_url }}
Keep customers engaged with latest content
Shop/Collections
{{ routes.collections_url }}
Direct customers to browse products
Account page
{{ routes.account_url }}
Default Shopify behavior
Cart page
{{ routes.cart_url }}
If customer was in checkout flow
Current page
{{ request.url }}
Return to where they were browsing
Specific collection
{{ collections['collection-handle'].url }}
Guide to relevant products
Custom page
{{ pages['page-handle'].url }}
Send to special offers or announcements
Troubleshooting common issues
Redirect not working
Check form structure: Ensure the hidden input is inside the correct form
Verify liquid syntax: Make sure Liquid code is properly formatted
Clear cache: Clear your browser cache and try again
Check theme updates: Some theme updates might override custom code
Redirect working inconsistently
URL encoding: Make sure special characters in URLs are properly encoded
Browser differences: Test across different browsers
Mobile vs desktop: Verify behavior on different devices
Breaking other functionality
Test thoroughly: Check that other login-related features still work
Backup first: Always backup your theme before making changes
Monitor customer behavior: Watch for increased bounce rates or confusion
FAQs
Will this affect the mobile app or other integrations?
The redirect modification typically only affects the web storefront. Mobile apps and other integrations may have their own login flows.
Can I set different redirects for different customer groups?
Yes, using the JavaScript or Shopify Scripts methods, you can create conditional redirects based on customer attributes, tags, or other criteria.
What happens if I update my theme?
Theme updates may override your custom code. Always backup your modifications and be prepared to re-implement them after major theme updates.
Can I redirect to external URLs?
For security reasons, it's generally not recommended to redirect to external URLs. Stick to pages within your Shopify store.
How do I revert to the default behavior?
Simply remove the hidden input field you added, and customers will be redirected to their account page by default.
Additional resources
Shopify Scripts Documentation (Shopify Plus)
Last updated
Was this helpful?