How maartenba/googleanalyticstracker works
Project type and purpose
• This is a multi-project .NET solution containing:
• A core C# library (GoogleAnalyticsTracker.Core) that implements the tracking logic and parameter models
• Two integration libraries:
– GoogleAnalyticsTracker.Simple for console/WPF/WinForms
– GoogleAnalyticsTracker.AspNetCore to hook into the ASP.NET Core pipeline via middleware and attributes
• A sample ASP.NET Core MVC web application (GoogleAnalyticsTracker.SampleWebApplication) demonstrating how to use the AspNetCore package
• A Nuke-based build script under build/ and a solution file to orchestrate building, testing, and packaging
• Purpose: Provide reusable, framework-agnostic tracking logic plus framework‐specific extensions so C# applications can send page-view and event hits to Google Analytics.
File structure
• Top-level projects and their roles:
• GoogleAnalyticsTracker.Core/ – tracking engine, data models, HTTP request wrappers, interfaces for session/environment customization
• GoogleAnalyticsTracker.Simple/ – concrete SimpleTracker and environment for standalone apps
• GoogleAnalyticsTracker.AspNetCore/ – middleware (UseGoogleAnalyticsTracker), DI registration, controller attributes ([TrackPageView], [TrackEvent])
• GoogleAnalyticsTracker.SampleWebApplication/ – ASP.NET Core MVC app showing controller usage, views, static assets, appsettings
• build/ – Nuke build definition to compile all projects, run tests, produce NuGet packages
• Solution and global config files manage versions and cross-project settings
• Key patterns: layered modular libraries, attribute-based AOP for request tracking, middleware pipeline, dependency injection.
README for additional insights
• The README describes usage scenarios for each package variant and configuration options
• It notes the customizable extension points (IAnalyticsSession, ITrackerEnvironment, override methods)
• It describes how the AspNetCore package hooks into Startup.ConfigureServices and Configure
Elements
• From SampleWebApplication to AspNetCore package (runtime reference)
• From AspNetCore/Simple to Core (compile and runtime dependency)
• From Core to External HTTP Endpoint (runtime data flow)
• From Build Script to each project (build-time action)
Be detailed and capture essential architectural elements
• How customization hooks (IAnalyticsSession, ITrackerEnvironment) sit in Core and are surfaced by the adapters.
• Separation of concerns: the Core library has no web dependencies, the AspNetCore adapter only wires Core into ASP.NET Core.
• Both automatic tracking (middleware) and manual tracking (method calls in controllers or console code).