/// <summary>
        /// Tracks the event and puts the result in a container object.
        /// </summary>
        /// <param name="analyticsEvent"></param>
        /// <returns>The result of the tracking operation</returns>
        public TrackingResult TrackEvent(IUniversalAnalyticsEvent analyticsEvent)
        {
            var result = new TrackingResult();

            try
            {
                string postData = this._postDataBuilder.BuildPostDataString(MEASUREMENT_PROTOCOL_VERSION, analyticsEvent);
                this._googleDataSender.SendData(GOOGLE_COLLECTION_URI, postData);
            }
            catch (Exception e)
            {
                result.Exception = e;
            }

            return(result);
        }
        /// <summary>
        /// Tracks the event and puts the result in a container object.
        /// </summary>
        /// <param name="analyticsEvent"></param>
        /// <returns>The result of the tracking operation</returns>
        public async Task <TrackingResult> TrackEventAsync(IUniversalAnalyticsEvent analyticsEvent)
        {
            var result = new TrackingResult();

            try
            {
                var postData = this._postDataBuilder.BuildPostDataCollection(MEASUREMENT_PROTOCOL_VERSION, analyticsEvent);
                await this._googleDataSender.SendDataAsync(GOOGLE_COLLECTION_URI, postData);
            }
            catch (Exception e)
            {
                result.Exception = e;
            }

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Validates current event (and existing payload data) and puts the result in a container object
        /// </summary>
        /// <param name="analyticsEvent">Events to track</param>
        /// <returns>The result of the hit validation operation</returns>
        public TrackingResult ValidateHit(IUniversalAnalyticsEvent analyticsEvent)
        {
            var result = new TrackingResult();

            try
            {
                string postData = this._postDataBuilder.BuildPostDataString(MEASUREMENT_PROTOCOL_VERSION, analyticsEvent, _customPayload);
                result.ValidationResult = _googleDataSender.SendData(GOOGLE_COLLECTION_URI_DEBUG, postData, /*bReadResponse*/ true);
            }
            catch (Exception e)
            {
                result.Exception = e;
            }

            return(result);
        }