Class GoogleAnalytics4Provider

    • Constructor Detail

      • GoogleAnalytics4Provider

        public GoogleAnalytics4Provider​(RestTemplate restTemplate,
                                        String measurementId,
                                        String apiSecret)
        Create a new Google Analytics 4 provider.
        Parameters:
        restTemplate - a REST template for performing requests with the collect API
        measurementId - a measurement ID which may be empty
        apiSecret - an API secret, must be non-empty if measurementId is supplied
    • Method Detail

      • setClientIdRetrievalStrategy

        public void setClientIdRetrievalStrategy​(ClientIdRetrievalStrategy clientIdRetrievalStrategy)
        Set the strategy used to retrieve client IDs.
      • setUserIdRetrievalStrategy

        public void setUserIdRetrievalStrategy​(UserIdRetrievalStrategy userIdRetrievalStrategy)
        Set the strategy used to retrieve user IDs.
      • setDebug

        public void setDebug​(boolean debug)
        Enable the debug mode.

        When debug mode is enabled, a testing GA4 endpoint will be used and sendEvent(String, Date, Map) may raise exception instead of simply warning.

      • setResolutionMillis

        public void setResolutionMillis​(long resolutionMillis)
        Time resolution for regrouping events in the same batch.

        Events with the same client and user IDs are batched together if they are less than the resolution apart and reported at the time the first event in the batch occurred.

        Setting this to zero effectively disable batching of events unless they occur at exactly the same time. This can be achieved by reusing the Date object when sending multiple events.

      • setPollingIntervalMillis

        public void setPollingIntervalMillis​(long pollingIntervalMillis)
        Interval at which events are polled and flushed.
      • sendEvent

        public void sendEvent​(String eventName,
                              Date date,
                              Map<String,​String> params)
        Description copied from interface: AnalyticsProvider
        Publish an event.
        Specified by:
        sendEvent in interface AnalyticsProvider
        Parameters:
        eventName - a name for the event
        date - an exact moment when the event occurred
        params - additional parameters for the event