I'd like to add Google event tracking to my PHP contact form. Doing so requires me to add a particular value to the 'onsubmit' attribute of the element. My PHP file already has an 'onsubmit' attribute defined. When I delete that attribute and enter the required Google code, nothing happens when I click the 'Submit' button (i.e. form does not submit, 'Thank You' page does not load, etc).
Here is the existing PHP code:
<form
class="cpp_form"
name="<?php echo $this->prefix; ?>_pform<?php echo '_'.$this->print_counter; ?>"
id="<?php echo $this->prefix; ?>_pform<?php echo '_'.$this->print_counter; ?>"
action="<?php $this->get_site_url(); ?>" method="post" enctype="multipart/form-data"
onsubmit="return <?php echo $this->prefix; ?>_pform_doValidate<?php echo '_'.$this->print_counter; ?>(this);">
Here is the Google code I need to enter for onsubmit:
_gaq.push([‘_trackEvent’, ‘button’, ’clicked’, ’contact us’,, ’true’])
Any ideas on how to do this/what I'm doing wrong?
I've also tried entering the Google code as the value for the "onclick" attribute. When I do that, the form can successfully be submitted, but it does not show up as an 'event' in Google Analytics.