function handleClick(event) {
  const rootNode = document;
  let element = event.target;

  while (element && element !== rootNode) {
    const category = element.getAttribute('data-ga-event-category');

    // We reach a tracking element, no need to look higher in the dom tree.
    if (category) {
      window.ga('send', {
        hitType: 'event',
        eventCategory: category,
        eventAction: element.getAttribute('data-ga-event-action'),
        eventLabel: element.getAttribute('data-ga-event-label'),
      });
      break;
    }

    element = element.parentNode;
  }
}
function handleClick(event) {
  const rootNode = document;
  let element = event.target;

  while (element && element !== rootNode) {
    const category = element.getAttribute('data-ga-event-category');

    // We reach a tracking element, no need to look higher in the dom tree.
    if (category) {
      window.ga('send', {
        hitType: 'event',
        eventCategory: category,
        eventAction: element.getAttribute('data-ga-event-action'),
        eventLabel: element.getAttribute('data-ga-event-label'),
      });
      break;
    }

    element = element.parentNode;
  }
}
function handleClick ( event ) { const rootNode = document ; let element = event . target ; while ( element && element !== rootNode ) { const category = element . getAttribute ( 'data-ga-event-category' ) ; // We reach a tracking element, no need to look higher in the dom tree. if ( category ) { window . ga ( 'send' , { hitType : 'event' , eventCategory : category , eventAction : element . getAttribute ( 'data-ga-event-action' ) , eventLabel : element . getAttribute ( 'data-ga-event-label' ) , } ) ; break ; } element = element . parentNode ; } }
So we can write code like:  <Button ga-event-category="demo" ga-event-action="expand" > Foo </Button>
So we can write code like : <Button ga - event - category = demo ga - event - action = expand > Foo < / Button >
Handle click events