Class GoogleAnalyticsDataPublisher


  • public class GoogleAnalyticsDataPublisher
    extends Object
    This class is responsible for publishing analytics data using the Measurement Protocol. Please refer: https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide
    • Constructor Detail

      • GoogleAnalyticsDataPublisher

        public GoogleAnalyticsDataPublisher()
    • Method Detail

      • publishPOST

        public static boolean publishPOST​(List<org.apache.http.NameValuePair> payload,
                                          String userAgent,
                                          boolean useSSL)
        Use this method to publish using POST.
        Parameters:
        payload - - use the buildPayload method to retrieve NameValuePair to use as payload here.
        userAgent - - set the userAgent - this can be overridden if userAgentOverride (ua) is set in payload
        useSSL - - to publish using HTTPS, set this value to true.
        Returns:
      • publishGET

        public static boolean publishGET​(String payload,
                                         String userAgent,
                                         boolean useSSL)
        Use this method to publish using GET.
        Parameters:
        payload - - use the buildPayloadString method to retrieve query param string to pass as payload here.
        userAgent - - set the userAgent - this can be overridden by using
        useSSL - - to publish using HTTPS, set this value to true.
        Returns:
      • buildPayloadString

        public static String buildPayloadString​(Object o)
        Use this method to retrieve a payload as string.
        Parameters:
        o - a GoogleAnalyticsData object
        Returns:
        query param string
      • buildPayload

        public static List<org.apache.http.NameValuePair> buildPayload​(Object o)
        Use this method to retireve a payload a list of NameValuePair.
        Parameters:
        o - a GoogleAnalyticsData object
        Returns:
        list of NamevaluePairs to be used in httpclient entity