public AnalyticsClient(string domain, string trackingCode) { Random randomNumber = new Random(); m_sessionVariables = new CustomVariableBag(); Timestamp = ConvertToUnixTimestamp(DateTime.Now).ToString(); Domain = domain; RandomNumber = randomNumber.Next(1000000000).ToString(); TrackingCode = trackingCode; UserAgent = GetDefaultUserAgent(); }
public void SubmitPageView(string page, string title, CustomVariableBag pageVariables) { var client = BuildBaseWebClient(page, title); var variables = m_sessionVariables.MergeWith(pageVariables); if (variables.Any()) { client.QueryString["utme"] = variables.ToUtme(); } client.DownloadDataAsync(new Uri("__utm.gif", UriKind.Relative)); }
public CustomVariableBag MergeWith(CustomVariableBag other) { var variables = new KeyValuePair <string, string>?[5]; m_variables.CopyTo(variables, 0); for (int i = 0; i < 5; i++) { if (other.m_variables[i] != null) { variables[i] = other.m_variables[i]; } } return(new CustomVariableBag(variables)); }
public CustomVariableBag MergeWith(CustomVariableBag other) { var variables = new KeyValuePair<string, string>?[5]; m_variables.CopyTo(variables, 0); for (int i = 0; i < 5; i++) { if (other.m_variables[i] != null) { variables[i] = other.m_variables[i]; } } return new CustomVariableBag(variables); }
public void SubmitTiming(string page, string title, string category, string action, int time, string label, CustomVariableBag pageVariables) { var client = BuildBaseWebClient(page, title); client.QueryString["utmt"] = "event"; client.QueryString["utme"] = FormatTimingUtme(category, action, time, label); var variables = m_sessionVariables.MergeWith(pageVariables); if (variables.Any()) { client.QueryString["utme"] += variables.ToUtme(); } client.DownloadDataAsync(new Uri("__utm.gif", UriKind.Relative)); }
public void SubmitEvent(string page, string title, string category, string action, string label, string value, CustomVariableBag pageVariables) { var client = BuildBaseWebClient(page, title); client.QueryString["utmt"] = "event"; client.QueryString["utme"] = FormatUtme(category, action, label, value); var variables = m_sessionVariables.MergeWith(pageVariables); if (variables.Any()) { client.QueryString["utme"] += variables.ToUtme(); } ThreadPool.QueueUserWorkItem(state => { client.DownloadDataAsync(new Uri("__utm.gif", UriKind.Relative)); }); }
public void SubmitTiming(string page, string title, string category, string action, int time, string label, CustomVariableBag pageVariables) { var client = BuildBaseWebClient(page, title); client.QueryString["utmt"] = "event"; client.QueryString["utme"] = FormatTimingUtme(category, action, time, label); var variables = m_sessionVariables.MergeWith(pageVariables); if (variables.Any()) client.QueryString["utme"] += variables.ToUtme(); ThreadPool.QueueUserWorkItem(state => { client.DownloadDataAsync(new Uri("__utm.gif", UriKind.Relative)); }); }
public void SubmitPageView(string page, string title, CustomVariableBag pageVariables) { var client = BuildBaseWebClient(page, title); var variables = m_sessionVariables.MergeWith(pageVariables); if (variables.Any()) client.QueryString["utme"] = variables.ToUtme(); ThreadPool.QueueUserWorkItem(state => { client.DownloadDataAsync(new Uri("__utm.gif", UriKind.Relative)); }); }