Reputation: 11
I want to track how many people sign up for Newsletters. I can do it with event tracking in Google Analytics. But there is an issue. I found the below code on the button
<form name="ccoptin" action="http://visitor.r20.constantcontact.com/d.jsp" target="_blank" method="post" onsubmit="return SubscribeValidate()">
Then where I have to place the following code
onClick="_gaq.push(['_trackEvent', 'newsletter signup', 'email', 'Sidebar',, false]);"
Upvotes: 0
Views: 1250
Reputation: 7270
onClick is tracking for buttons. For forms, add the code into a successful "validate" function and/or on the "thank you" page.
var SubscribeValidate = function () {
// Make sure the form is filled out
if ($("#email").text() != "") {
return false;
}
// Track in Google Analytics
_gaq.push(['_trackEvent', 'newsletter signup', 'email', 'Sidebar', , false]);
window.location = "/thanks"; // or $("#modal").modal();
}
Upvotes: 1