Showing results for 
Search instead for 
Did you mean: 

Adding Analytics Event to Google API

Adding Analytics Event to Google API


Magento Version:


I’ve had my Google Analytics working fine using the below script placed in System>Configuration>General>Design>Footer>Miscellaneous HTML


I want to add e-commerce tracking using the built-in Google API and keep my custom “30 seconds on page” event but I’m not sure how to do both.


How do I add a custom event when using the built-in Google Analytics API?


  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  ga('create', 'UA-******-*', 'auto');
  ga('send', 'pageview');setTimeout("ga('send', 'event', { eventCategory: '30 seconds on page', eventAction: 'Read' })", 30000);



 I’ve tried adding the event code to app/code/core/Mage/GoogleAnalytics/Block/Ga.php but keep getting a error.


Any help would be appreciated.