I think that when checking in Google Analytics, you select "Universal Analytics" and use a new code counter. Look in the DOM browser, there is no "_gaq" object - and therefore is an error. You tried to fix it with an empty array (_gaq).
Old code:
var _gaq = _gaq | | [];
_gaq.push (['_ setAccount', 'UA-XXXXXX-1']);
Do not use the old code! (And you cannot use the counter of several codes 'UA-XXXXXX-1' - this is an error)
New code:
ga ('create', 'UA-XXXXXXX-1', 'mysite.com');
ga ('send', 'pageview');
The new Google counter has a new syntax.
Event Use Documentation: https://developers.google.com/analytics/devguides/collection/analyticsjs/events
Usage example:
I have a calculator on the page and I want to track events by clicking a button on it.
Category - Using Calculator,
Event - "Cost Calculation".
Old code:
_gaq.push (['_ trackEvent', 'Using the calculator', 'Calculation of cost'),
New code:
ga ('send', 'event', 'Using the calculator', 'Cost calculation'),
Category and event - required!
PS: Sorry. I have bad English and I used google translator :)
Upd:
<script type='text/javascript'> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); //Use once per page ga('create', 'UA-1234556-1', 'domain.com'); ga('send', 'pageview'); // function submit_data(){ var text_area=$('#textarea').val(); var url ="functions.php"; jQuery.ajax({ type: "get", dataType: "text", url: url, data: { what : "generate", text_area: text_area, t: Math.random() }, success: function(data, textStatus){ $('#textarea').val(data); ga('send', 'event', 'MyCategory', 'functions.php'); } }); } </script>