function trackCustomEvent({
  category,
  action,
  label,
  value,
  nonInteraction = false,
  transport,
  hitCallback,
  callbackTimeout = 1000,
}) {
  if (typeof window !== `undefined` && window.ga) {
    const trackingEventOptions = {
      eventCategory: category,
      eventAction: action,
      eventLabel: label,
      eventValue: value,
      nonInteraction: nonInteraction,
      transport,
    }

    if (hitCallback && typeof hitCallback === `function`) {
      trackingEventOptions.hitCallback = createFunctionWithTimeout(
        hitCallback,
        callbackTimeout
      )
    }

    window.ga(`send`, `event`, trackingEventOptions)
  }
}
This allows the user to create custom events within their Gatsby projects.

@param {import('gatsby-plugin-google-analytics').CustomEventArgs} args
@see https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#events