I would like to send event when someone submits form on my website, but it's not working.
当有人在我的网站上提交表格时,我想发送活动,但它不起作用。
This is my form script:
这是我的表单脚本:
$('.wicmsLeadSubmit').prop( 'disabled', false );
$('.wicmsLeadSubmit').click(function(){
var leadForm = $(this).closest('form');
var leadImie = $('.lead_imie', leadForm);
var leadTelefon = $('.lead_telefon', leadForm);
var leadEmail = $('.lead_email', leadForm);
if(leadImie.length){
if(leadImie.val()==''){
leadImie.attr('placeholder', 'Podaj imię');
return false;
}
}
if(leadEmail.length){
if(leadEmail.val() == ''){
leadEmail.attr('placeholder', 'Podaj email');
return false;
}
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(reg.test(leadEmail.val()) == false) {
leadEmail.val('');
leadEmail.attr('placeholder', 'Podałeś błędny email');
return false;
}
}
ga('send', 'event', 'Submit', 'Modal Rejestracja', $('.reveal-modal.formularz').id());
ga('set', 'userId', leadEmail.val() );
$.ajax({
type: 'POST',
url: '/lead',
dataType: 'json',
data: {
lead_email: leadEmail.val(),
lead_imie: leadImie.val(),
lead_source: $(':hidden.lead_source', leadForm).val(),
lead_telefon: leadTelefon.val()
},
success: function(data){
if(data.error.exists==true){
$('.powiadomienie', leadForm).hide();
$('.blad', leadForm).show();
$('.blad', leadForm).append(' Tresc błedu: '+data.error.message);
$('.wicmsLeadSubmit', leadForm).prop( 'disabled', true );
}
else{
$('.wicmsLeadSubmit', leadForm).prop( 'disabled', true );
$('.powiadomienie', leadForm).show();
}
},
});
return false;
});
And this is what makes error: ga('send', 'event', 'Submit', 'Modal Rejestracja', $('.reveal-modal.formularz').id());
这就是错误:ga('发送','事件','提交','模态Rejestracja',$('。reveal-modal.formularz')。id());
And when I try to look for errors there is only one: $(...).id is not a function
当我试图寻找错误时,只有一个:$(...)。id不是一个函数
Please help.
1 个解决方案
#1
0
.id()
is not a jQuery function, if you want the id
attribute, do this:
.id()不是jQuery函数,如果你想要id属性,可以这样做:
ga('send', 'event', 'Submit', 'Modal Rejestracja', $('.reveal-modal.formularz').attr('id'));
#1
0
.id()
is not a jQuery function, if you want the id
attribute, do this:
.id()不是jQuery函数,如果你想要id属性,可以这样做:
ga('send', 'event', 'Submit', 'Modal Rejestracja', $('.reveal-modal.formularz').attr('id'));