/// <summary> /// Track the download event /// </summary> /// <param name="path"></param> /// <param name="context"></param> /// <param name="bytes"></param> private static void TrackDownloadEvent(string path, HttpContextWrapper context, long bytes) { ConfigurationManager.AppSettings["GoogleAnalyticsAccountCode"] = SettingsHelper.GetGoogleAnalyticsProfile(); var code = GaDotNet.Common.Data.ConfigurationSettings.GoogleAccountCode; string referrer = "NoReferrer"; if (context.Request != null && context.Request.UrlReferrer != null) { referrer = context.Request.UrlReferrer.Host; } int kiloBytes = (int)(bytes / 1024); GoogleEvent googleEvent = new GoogleEvent("http://localhost.local", "Download", referrer, path, kiloBytes); var app = (HttpApplication)context.GetService(typeof(HttpApplication)); TrackingRequest request = new RequestFactory().BuildRequest(googleEvent, app.Context); GoogleTracking.FireTrackingEvent(request); }