skip to Main Content

I want to have two mailchimp forms ( linked to the same mailchimp list ) within the same landingpage in a Shopify Store. *it is a long landing page so I want them to be able to subscribe two times along the way.

It seems the second form does not work and the only think it does is refreshing the page. I am pretty sure there is a conflict with their ID´s because the two forms have the same ID ( id=”mailchimp” ) but I believe it is neccesary for them to work.

I may have a very easy-to-resolve question but i have been struggling with it for a while. It seems there is no documentation about it ( apart from inserting one of the forms within an iframe -> I am not confortable with this solution because I want to record with GTM ( GA ) customer succesuful submitions etc. ).

The code for the forms ( snippet that it is called two times within the page ):

<!-- Newsletter Section -->
        <section id="services" class="small-section bg-gray-lighter">
            <div class="container relative">
                <form class="form align-center newsdown" id="mailchimp">
                    <div class="row">
                        <div class="col-md-8 col-md-offset-2">
                            <div class="mb-20">
                                <input placeholder="Introduce tu email" class="newsletter-field form-control input-md round mb-xs-10" type="email" pattern=".{5,100}" required/>

                                <button type="submit" class="btn btn-mod btn-border-c btn-medium btn-round mb-xs-10">
                                    Suscribe
                                </button>
                            </div>


                            <div id="subscribe-result"></div>

                        </div>
                    </div>
                </form>

            </div>
        </section>
        <!-- End Newsletter Section -->

What can I do to have these two identical forms working on the same page? Have in mind I don’t have access to the javascript ( because mailchimp has Shopify app that makes this connection ).

2

Answers


  1. Chosen as BEST ANSWER

    As it appeared there were a conflict with two exact forms ( same javascript etc ) so I implemented the second form differently:

    <!-- Newsletter Section -->
        <section id="services" class="small-section bg-gray-lighter">
            <div class="container relative">
                 <form action="YOURACTION;id=YOURID" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
                     <div class="row">
                         <div class="col-md-8 col-md-offset-2" style="text-align: center;">  
                             <div class="newsletter-label font-alt">
                                ¿Te interesa? Recibe más noticias y tutoriales exclusivos  
                                </div>
                                <div class="mb-20">
                                    <input name="EMAIL" id="mce-EMAIL" placeholder="Introduce tu email" class="newsletter-field form-control input-md round mb-xs-10 required email" type="email" pattern=".{5,100}" required/>
    
                                    <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button btn btn-mod btn-border-c btn-medium btn-round mb-xs-10">
                                </div>
                      <div id="mce-responses" class="clear">
                          <div class="response" id="mce-error-response" style="display:none"></div>
                          <div class="response" id="mce-success-response" style="display:none"></div>
                      </div>    
                      <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
                      <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_5307a1008b76c5446a7303622_18658ede2a" tabindex="-1" value=""></div>
                                <div class="form-tip">
                                    <i class="fa fa-info-circle"></i> Pocos emails, pero de calidad. Nunca Spam. Te servirán.
                                </div>
                                <div id="subscribe-result"></div>
                            </div>
                        </div>
                    </form>
                </div>
            </section>
            <!-- End Newsletter Section -->
    
    <script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script><script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';fnames[3]='MMERGE3';ftypes[3]='dropdown';fnames[4]='MMERGE4';ftypes[4]='phone';fnames[5]='MMERGE5';ftypes[5]='url';fnames[7]='MMERGE7';ftypes[7]='text';fnames[6]='MMERGE6';ftypes[6]='birthday';fnames[8]='MMERGE8';ftypes[8]='text';fnames[9]='MMERGE9';ftypes[9]='radio';}(jQuery));var $mcj = jQuery.noConflict(true);</script>
    <!--End mc_embed_signup-->
    

  2. If you wrap each mailchimp form in a …., then run this script on the page, it will re-assign all IDs of the non-focused form, and re-bind the submit event. A bit hacky, but it works if you’re in a bind.

    $(document).ready(function() {
    
    // only execute if confirmed more than 1 mailchimp form on this page
    if ( $('.mc-form-instance').length > 1 ) {
    
        $('.mc-field-group > .required').on('focus', function() {
            var thisField = $(this);
    
            // backup all mc-form ids on this page
            $('.mc-form-instance [id]').each(function() {
                var currentID = $(this).attr('id');
                if ( currentID.indexOf('-bak') == -1 ) {
                    $(this).attr('id', currentID + '-bak');
                }
            });
            // change the current form ids back to original state
            var thisForm = thisField.closest('.mc-form-instance');
            thisForm.find('[id]').each(function() {
                var currentID = $(this).attr('id');
                if ( currentID.indexOf('-bak') != -1 ) {
                    $(this).attr('id', currentID.replace('-bak', ''));
                }
            });
        });
        // re-bind
        $.getScript('//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js');
      }
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search