Customize the redirect URL after login

You might want to customize the URL that users get redirected to after a successful login in order to better integrate your login page with the MobiLoud app. To do this, you can modify your theme code as follows:

Step-by-Step Tutorial

Access the Theme Code:

  1. Log in to your Shopify admin panel.
  2. Go to Online Store > Themes.
  3. Find the theme you want to edit and click on Actions > Edit Code.

Locate the Login Form Code:

  1. In the theme editor, find the file that contains the customer login form. This is usually located in Sections or Templates, and the file might be named customers/login.liquid or something similar.
  2. Open the file to edit the code.

Add a Form ID:

Locate the form tag for the customer login form. Add an id attribute to the form tag for easy reference in JavaScript. Your form tag should look something like this:

{%- form 'customer_login', novalidate: 'novalidate', id: 'customer_login_form' -%}

Insert the JavaScript Snippet:

Add the following JavaScript code at the bottom of the same file. This script checks if the user's user agent contains the string "canvas" (case insensitive) and updates the form action URL accordingly:

<script>
  document.addEventListener('DOMContentLoaded', function() {
    var form = document.getElementById('customer_login_form');
    if (navigator.userAgent.toLowerCase().includes('canvas')) {
      form.action += '?app_login=true';
    }
  });
</script>

After adding the JavaScript code, save the changes by clicking the Save button in the top-right corner of the theme editor.

Thank you! We'll be in touch within 48 hours :)
Oops! Something went wrong while submitting the form.