src/runtime/google-analytics-event-listener.js
/**
   *  Listens for new events from the events manager and logs appropriate events to Google Analytics.
   * @param {!../api/client-event-manager-api.ClientEvent} event
   */
Listens for new events from the events manager and logs appropriate events to Google Analytics.
Listens for new events from the events manager and logs appropriate events to Google Analytics .
handleClientEvent_(event) {
    if (typeof this.win_.ga != 'function') {
      return;
    }
    let subscriptionFlow = '';
    if (event.additionalParameters) {
      subscriptionFlow =
        event.additionalParameters.subscriptionFlow ||
        event.additionalParameters.getSubscriptionFlow();
    }
    const gaEvent = analyticsEventToGoogleAnalyticsEvent(
      event.eventType,
      subscriptionFlow
    );
    if (gaEvent) {
      this.win_.ga('send', 'event', gaEvent);
    }
  }
handleClientEvent_ ( event ) { if ( typeof this . win_ . ga != 'function' ) { return ; } let subscriptionFlow = '' ; if ( event . additionalParameters ) { subscriptionFlow = event . additionalParameters . subscriptionFlow || event . additionalParameters . getSubscriptionFlow ( ) ; } const gaEvent = analyticsEventToGoogleAnalyticsEvent ( event . eventType , subscriptionFlow ) ; if ( gaEvent ) { this . win_ . ga ( 'send' , 'event' , gaEvent ) ; } }
Listens for new events from the events manager and logs appropriate events to Google Analytics.
Listens for new events from the events manager and logs appropriate events to Google Analytics .
// Bail immediately if ga function doesn't exist in Window. // additionalParameters isn't strongly typed so checking for both object and class notation.