我正在尝试放置一个事件跟踪代码,而对于我的生活,它将无法正常工作。我已经在其他网站上完成了它,它没有任何问题。不确定是不是因为按钮代码不同。下面是按钮代码,我在下面放置了事件跟踪代码。请告诉我哪里出错了!
<div id="optin">
<form action="http://iuzeit.us7.list-manage1.com/subscribe/post?u=89560f169a7c1aa335b0885ff&id=16962f2a89" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<p>iuzeit will be ready for beta testing soon. Leave us your email address and we'll give you exclusive access!</p>
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
<div class="clear" style="padding-top:10px;">
<center>
<input type="submit" value="Subscribe" **onClick="_gaq.push(['_trackEvent', 'Register for Beta', 'Subscribe', 'Register on Blog Sidebar']);"** name="subscribe" id="mc-embedded-subscribe" class="button">
</center>
</div>
答案 0 :(得分:2)
我会在表单标记上使用onsubmit,而不是在输入标记上单击onclick。原因是只有在提交表单时才会触发事件,而不是每次单击按钮时触发事件。
您的表单标记如下所示:
<form action="http://iuzeit.us7.list-manage1.com/subscribe/post?u=89560f169a7c1aa335b0885ff&id=16962f2a89" method="post" onsubmit="_gaq.push(['_trackEvent', 'Register for Beta', 'Subscribe', 'Register on Blog Sidebar']);" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>