0

我需要将简报注册作为 Google Analytics 中的事件进行跟踪。我在哪里放置事件跟踪代码?我知道我必须将它放在“成功注册”验证所在的位置,但我不知道下面代码的哪一部分进行验证。

这是我的 GA 事件跟踪代码:

_gaq.push(['_trackEvent', 'Newsletter', 'Suscribe to Newsletter', 'Newsletter Form', 0, false]);

这是时事通讯注册表单:

<form action="http://www.somesite.com/index.php/newsletter/subscriber/new/"  method="post" id="newsletter-validate-detail">
<div class="block-content">
<div class="input-box">
<input type="text" name="email" id="newsletter" title="Subscribe to Newsletter" class="input-text required-entry validate-email" />
</div>
<div class="actions">
<button type="submit" title="Subscribe" class="button"><span><span>Send</span></span></button>
</div>
</div>
</form>

这是时事通讯的 javascript:

<script type="text/javascript">
//<![CDATA[
var newsletterSubscriberFormDetail = new VarienForm('newsletter-validate-detail');
Varien.newsletterForm = Class.create();
Varien.newsletterForm.prototype = {
initialize : function(form, field, emptyText){
this.form = $(form);
this.field = $(field);
this.emptyText = emptyText;
Event.observe(this.form, 'submit', this.submit.bind(this));
Event.observe(this.field, 'focus', this.focus.bind(this));
Event.observe(this.field, 'blur', this.blur.bind(this));
this.blur();
},
submit : function(event){
if (this.field.value == this.emptyText || this.field.value == ''){
Event.stop(event);
return false;
}
return true;
},
focus : function(event){
if(this.field.value==this.emptyText){
this.field.value='';
}
},
blur : function(event){
if(this.field.value==''){
this.field.value=this.emptyText;
}
}
}
var newsletterForm = new Varien.newsletterForm('newsletter-validate-detail',
'newsletter', 'Get the latest news');                                    
//]]>
</script>

在此先感谢您的帮助。

4

1 回答 1

2

这应该进入进行验证的提交功能(它有什么):

submit : function(event){
if (this.field.value == this.emptyText || this.field.value == ''){
    // does not validate so submit event is aborted
    Event.stop(event);
    return false; 
}
    //validates so it's reasonably safe to sent the event
    gaq.push(['_trackEvent', 'Newsletter', 'Suscribe to Newsletter', 'Newsletter Form', 0, false]); 
    return true;
}
于 2013-02-20T14:58:56.470 回答