Question

Can anyone see a problem with the code here for tracking this button? Fixed it from the previous post and still nothing with the new code:

<form id="constant-contact-signup2" action="http://www.truckingoffice.com/trucking-software-blog" method="post">
<div class="kws_input_fields">
<div class='cc_email_address kws_input_container'>
<label for='cc_email_address' class=''> Sign up for our Trucking Office Newsletter <span class="req" title="The  Sign up for our Trucking Office Newsletter  field is required">*</span></label>
<input type='text' value='' size="30"  placeholder='john.appleseed@apple.com' name='fields[email_address][value]' class='t  required' id='cc_email_address' />
<input type="hidden" name="fields[email_address][label]" value=" Sign up for our Trucking Office Newsletter " />
<input type="hidden" name="fields[email_address][req]" value="1" /></div>

<input type="submit" style='position:absolute; width:0;height:0;visibility:hidden!important;' name='constant-contact-signup-submit' onclick=”_gaq.push(['_trackEvent', 'Button', 'Click']);” />

Privacy by SafeSubscribe

Been working on this one all week and still nothing. Any al all help would be much appreciated!

Was it helpful?

Solution

_trackEvent and _trackPageview work by making a tracking pixel request to the Google servers -- you could be running into a timing problem where the image request is canceled because of a request for rendering a new page. A common solution is to delay the form submission a small amount after the tracking call.

Using jQuery, something like:

jQuery(function($){
  $('#constant-contact-signup2 input[type=submit]').click(function(e){
    e.preventDefault();
    _gaq.push(['_trackEvent', 'Button', 'Click']);
    setTimeout(function(){$('#constant-contact-signup2').submit()}, 150);
  });
})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top