GoogleAnalyticsUtils.EventsReporter.ReportEvent C# (CSharp) Method

ReportEvent() public method

public ReportEvent ( string source, string eventType, string eventName, bool userLoggedIn, string projectNumber = null, string>.Dictionary metadata = null ) : void
source string
eventType string
eventName string
userLoggedIn bool
projectNumber string
metadata string>.Dictionary
return void
        public void ReportEvent(
            string source,
            string eventType,
            string eventName,
            bool userLoggedIn,
            string projectNumber = null,
            Dictionary<string, string> metadata = null)
        {
            Preconditions.CheckNotNull(eventType, nameof(eventType));
            Preconditions.CheckNotNull(eventName, nameof(eventName));

            var customDimensions = new Dictionary<int, string>
            {
                { IsUserSignedInIndex, userLoggedIn ? TrueValue : FalseValue },
                { IsInternalUserIndex, FalseValue },
                { EventTypeIndex, eventType },
                { EventNameIndex, eventName },
                { IsEventHitIndex, TrueValue },
            };
            if (projectNumber != null)
            {
                customDimensions[ProjectNumberHashIndex] = GetHash(projectNumber);
            }
            var serializedMetadata = metadata != null ? SerializeEventMetadata(metadata) : null;

            _reporter.ReportPageView(
                page: GetPageViewURI(eventType: eventType, eventName: eventName),
                title: serializedMetadata,
                host: source,
                customDimensions: customDimensions);
        }

Usage Example

        public void SimpleEventTest()
        {
            var fakeReporter = new FakeAnalyticsReporterForEventsImpl(
                expectedEventType: FakeEventType,
                expectedEventName: FakeEventName,
                expectedHostName: FakeHostName);
            var eventsReporter = new EventsReporter(fakeReporter);

            eventsReporter.ReportEvent(
                source: FakeHostName,
                eventType: FakeEventType,
                eventName: FakeEventName,
                userLoggedIn: false);
        }
All Usage Examples Of GoogleAnalyticsUtils.EventsReporter::ReportEvent