Google Analytics implementation


I want to implement google analytics for my algolia search. I can only find this document Upgrade Guides for InstantSearch | Building Search UI | Guide | Algolia Documentation

const insightsMiddleware = instantsearch.middlewares.createInsightsMiddleware({

  insightsClient: window.aa,
  onEvent: (event, aa) => {
    const { insightsMethod, payload, widgetType, eventType } = event;	    

    // Send click events on Hits to a third-party tracker
    if (widgetType === 'ais.hits' && eventType === 'click') {
      thirdPartyTracker.send('Search Results Clicked', payload);


As far as I understand this will only send click event after search. How do I introduced other events such as Product Added to cart, Product Purchased, etc.
Similar way of sending events to algolia i.e. clickedObjectIDsAfterSearch, convertedObjectIDsAfterSearch, etc

Can anyone help me and give me some examples?