add custom script when login successfully

Patrick_Lin
Shopify Partner
1 0 0

I want to trigger a custom script about GTM code when the user login successfully. But the page will be redirected to other pages when the user clicks the login button. Does anyone know how to fix it?

 

    {% if shop.checkout.guest_login %}
      <div class="text-center">
        <hr class="hr--invisible">
        <h2>{{ 'customer.login.guest_title' | t }}</h2>

        {% form 'guest_login' %}
                  {% if form.posted_successfully? %}
            <span data-success class="hide"></span>
        <script>
console.log('Login successfully ') //doesn't work
   </script>
          {% endif %}
          <input type="submit" class="btn btn--primary btn--form" value="{{ 'customer.login.guest_continue' | t }}">
        {% endform %}
      </div>
    {% endif %}

 

Replies 0 (0)