jquery - Google Analytics Tracking Event Not Working -
i've added tracking event using jquery onclick using google analytics.js doesn't work @ all.. fire event undefined in response.
<script> (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'); ga('create', 'ua-36828246-2', 'curiousworkout.com'); ga('send', 'pageview'); </script> <script type="text/javascript"> jquery(document).ready(function(){ $('#generate_header').click(function(event){ event.preventdefault(); ga('generate_workout', 'header_click'); window.location = $(this).attr("href"); }); $('#generate_top_list').click(function(){ ga('generate_workout', 'top_list_click'); window.location = $(this).attr("href"); }); $('#generate_top_main').click(function(){ ga('generate_workout', 'top_main_click'); window.location = $(this).attr("href"); }); }); </script>
it looks me event submission lines missing lot of data, notably command send
event
.
from the universal analytics event tracking guide:
to send event, pass ga function
send
commandevent
hit typega('send', 'event', 'button', 'click', 'nav buttons', 4);
where:
button
categoryclick
actionnav buttons
label4
value
from code, assume "generate_workout" category of event action trying track , "top_main_click" action, , don't need value prescribed event.
this gives this:
ga('send', 'event', 'generate_workout', 'top_main_click');
if relevant, consider adding label attribute url of page action generated can track events come from.
Comments
Post a Comment