跟踪MailChimp嵌入式表单上的提交 [英] Tracking submissions on MailChimp embedded form

查看:88
本文介绍了跟踪MailChimp嵌入式表单上的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试跟踪嵌入式MailChimp表单上的提交.问题在于,提交表单时不会触发任何表单提交事件.我认为这与用于验证输入的JQuery有关.这是表单的嵌入代码:

I'm attempting to track submissions on a embedded MailChimp form. The problem is that no form submit event is fired when the form is submitted. I think this has to do with the JQuery being used to validate the input. Here's the embed code for the form:

<!-- Begin MailChimp Signup Form -->
<link href="//cdn-images.mailchimp.com/embedcode/classic-10_7.css" rel="stylesheet" type="text/css">
<style type="text/css">
    #mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }
    /* Add your own MailChimp form style overrides in your site stylesheet or in this style block.
       We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
</style>
<div id="mc_embed_signup">
<form action="https://carilionclinic.us16.list-manage.com/subscribe/post?u=#####;id=######" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
    <div id="mc_embed_signup_scroll">
    <h2>Subscribe to our mailing list</h2>
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
    <label for="mce-EMAIL">Email Address  <span class="asterisk">*</span>
</label>
    <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
    <label for="mce-MMERGE1">first name </label>
    <input type="text" value="" name="MMERGE1" class="" id="mce-MMERGE1">
</div>
<div class="mc-field-group">
    <label for="mce-MMERGE2">last name </label>
    <input type="text" value="" name="MMERGE2" class="" id="mce-MMERGE2">
</div>
<div class="mc-field-group">
    <label for="mce-MMERGE3">postal code </label>
    <input type="text" value="" name="MMERGE3" class="" id="mce-MMERGE3">
</div>
<div class="mc-field-group">
    <label for="mce-MMERGE4">Salutation </label>
    <input type="text" value="" name="MMERGE4" class="" id="mce-MMERGE4">
</div>
<div class="mc-field-group">
    <label for="mce-MMERGE5">Organization </label>
    <input type="text" value="" name="MMERGE5" class="" id="mce-MMERGE5">
</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_137cf6679807eccaef7f6f9d1_ae2345011d" tabindex="-1" value=""></div>
    <div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
    </div>
</form>
</div>
<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]='MMERGE1';ftypes[1]='text';fnames[2]='MMERGE2';ftypes[2]='text';fnames[3]='MMERGE3';ftypes[3]='text';fnames[4]='MMERGE4';ftypes[4]='text';fnames[5]='MMERGE5';ftypes[5]='text';}(jQuery));var $mcj = jQuery.noConflict(true);</script>
<!--End mc_embed_signup-->

如果检查mc-validate.js,您会发现该表单使用了JQuery Validation插件.我相信可能是问题所在?我总是可以跟踪提交"按钮上的点击,但这肯定不如表单提交准确.我可以使用另一种方法吗?

If you inspect mc-validate.js, you'll find that the form uses the JQuery Validation plugin. I believe it may be the issue? I can always track clicks on the submit button, but that's certainly not as accurate as a form submission would be. Is there an alternative method I can use?

推荐答案

您可以像这样触发对Google Analytics(分析)或GTM函数的调用,

You can trigger a call to your google analytics or GTM function like this,

$('form#mc-embedded-subscribe-form').submit(function(e) {
   //Your event goes here ex. dataLayer.push({'event':'eventname'});
   return true;
});

这将触发呼叫以跟踪表单提交.在触发事件之前进行验证(如果需要).

This will trigger a call to track form submissions. Do validations(if required) before triggering the event.

如果仅在表单经过验证后才需要提交表单,请使用内部提交功能中的e.preventDefault();停止提交表单.

If you need to submit form only if the form is validated, then stop the form submission using e.preventDefault(); inside submit function.

这篇关于跟踪MailChimp嵌入式表单上的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆