我正在尝试在我的WordPress网站上使用Woopra设置表单跟踪,但它不起作用。
在我的HTML表单下方:
<form id="subForm" class="af-form-wrapper wpcf7-form" action="http://campaign.clever-age.com/t/r/s/kuuhpd/" method="post" data-mautic-form="conferencemonitoringecp16">
<input id="fielddrhhqlu" class="text" name="cm-f-drhhqlu" required="" type="text" placeholder="Nom ( obligatoire )" />
<input id="fielddrhhqo" name="cm-f-drhhqo" required="" type="text" placeholder="Prenom (obligatoire)" />
<input id="fielddrhhqn" name="cm-f-drhhqn" required="" type="text" placeholder="Société (obligatoire)" />
<input id="fielddrhhqb" name="cm-f-drhhqb" required="" type="tel" placeholder="Téléphone (obligatoire)" />
<input id="fieldEmail" name="cm-kuuhpd-kuuhpd" required="" type="email" placeholder="Adresse E-mail (obligatoire)" />
<button id="mauticform_input_magento114form_submit" name="mauticform[submit]" type="submit">Recevoir le guide </button>
</form>
我想仅跟踪姓名,公司和电子邮件数据。在我的JS脚本下面:
<script>
woopra.call('trackForm', 'Magento2', 'subForm', {
identify: function(form) {
return {
Name: form.cm-f-drhhqlu,
Company: form.cm-f-drhhqn,
Email: form.cm-kuuhpd-kuuhpd
};
},
});
</script>
非常感谢任何帮助! : - )
答案 0 :(得分:0)
在我的解决方案之下。
HTML:
<form id="subForm" class="af-form-wrapper wpcf7-form" action="http://campaign.clever-age.com/t/r/s/kuuhpd/" method="post" data-mautic-form="conferencemonitoringecp16" onsubmit="identify()">
<input id="fielddrhhqlu" class="text" name="cm-f-drhhqlu" required="" type="text" placeholder="Nom ( obligatoire )" />
<input id="fielddrhhqo" name="cm-f-drhhqo" required="" type="text" placeholder="Prenom (obligatoire)" />
<input id="fielddrhhqn" name="cm-f-drhhqn" required="" type="text" placeholder="Société (obligatoire)" />
<input id="fielddrhhqb" name="cm-f-drhhqb" required="" type="tel" placeholder="Téléphone (obligatoire)" />
<input id="fieldEmail" name="cm-kuuhpd-kuuhpd" required="" type="email" placeholder="Adresse E-mail (obligatoire)" />
<button id="mauticform_input_magento114form_submit" name="mauticform[submit]" type="button" onclick="identify();">Recevoir le guide </button>
</form>
JS:
<script type="text/javascript"><!--
$(function() {
woopra.call('trackForm', 'Magento', '#subForm', {
});
});
function identify() {
var emailField = document.getElementById('fieldEmail').value;
var nameField = document.getElementById('fielddrhhqo').value + " " + document.getElementById('fielddrhhqlu').value;
var companyField = document.getElementById('fielddrhhqn').value;
woopra.identify({
email: emailField,
name: nameField,
company: companyField
}).push(submitForm);
}
function submitForm() {
var form = document.getElementById("subForm");
form.submit();
}
--></script>
希望如果有人面临同样的问题会有所帮助。