Monday, April 16, 2012

'syntax error, unexpected T_CONSTANT_ENCAPSED_STRING' Adding google event tracking to button in Wordpress Plugin

I'm attempting to add a google event tracking to a wordpress plugin. The code for the submit button in this plugin is:



{
return "<input type=\"submit\" ".
"name=\"".fm_form_submit_btn_name()."\" ".
"id=\"".fm_form_submit_btn_id()."\" ".
"class=\"submit\" ".
"value=\"".fm_form_submit_btn_text()."\" ".
"onclick=\"".fm_form_submit_btn_script()."\" ".
" />\n";
}


I'm trying to add google analytics tracking code onclick=_gaq.push(['_trackEvent', 'Form', 'Submit', 'Apply']) to the above block, and eventually replace 'Apply' with fm_form_the_title() which returns the title of the form.



The problem: No matter what arrangement of quotes I use when inserting the tracking code block, I am faced with an error 'syntax error, unexpected T_CONSTANT_ENCAPSED_STRING' or 'T_STRING' which shuts down the entire site.



EDIT: The code block above works, and does not need simplifying, and is part of a much larger project. My question is how to add onclick=_gaq.push(['_trackEvent', 'Form', 'Submit', 'Apply']) and eventually replace 'Apply' with fm_form_the_title() and NOT break my website.





No comments:

Post a Comment