private void Track() { using (var tracker = new Tracker("UA-29860952-1", "ezweather")) { tracker.TrackPageView("AddCityView", "AddCityView"); } }
private void Track() { using (var tracker = new Tracker("UA-29860952-1", "ezweather")) { tracker.TrackPageView("Settings", "Settings"); } }
public virtual void OnTrackingAction(ActionExecutingContext filterContext) { Tracker.TrackPageView( filterContext.RequestContext.HttpContext, BuildCurrentActionName(filterContext), BuildCurrentActionUrl(filterContext) ); }
public static void TrackPageView(this Tracker tracker, HttpRequestMessage httpRequest, string pageTitle, string pageUrl) { tracker.TrackPageView(pageTitle, pageUrl, hostname: httpRequest.RequestUri.Host, userAgent: httpRequest.Headers.UserAgent.ToString(), language: httpRequest.Headers.AcceptLanguage.ToString() ); }
public static void TrackPageView(this Tracker tracker, System.Net.Http.HttpRequestMessage request, string pageTitle, string pageUrl) { tracker.Hostname = request.Headers.From; tracker.UserAgent = request.Headers.UserAgent != null?string.Join(";", request.Headers.UserAgent) : ""; tracker.Language = request.Headers.AcceptLanguage != null?string.Join(";", request.Headers.AcceptLanguage) : ""; tracker.TrackPageView(pageTitle, pageUrl); }
public static void TrackPageView(this Tracker tracker, HttpContextBase httpContext, string pageTitle, string pageUrl) { var request = httpContext.Request; tracker.Hostname = request.UserHostName; tracker.UserAgent = request.UserAgent; tracker.Language = request.UserLanguages != null?string.Join(";", request.UserLanguages) : ""; tracker.TrackPageView(pageTitle, pageUrl); }
public static void TrackPageView(this Tracker tracker, HttpContextBase httpContext, string pageTitle, string pageUrl) { var request = httpContext.Request; tracker.TrackPageView(pageTitle, pageUrl, hostname: request.Url.Host, userAgent: request.UserAgent, language: request.UserLanguages != null ? string.Join(";", request.UserLanguages) : "" ); }
public Main() { InitializeComponent(); //Message.Visibility = Visibility.Collapsed; AnimationContext = LayoutRoot; Loaded += (s, e) => { using (var tracker = new Tracker("UA-29860952-1", "ezweather")) { tracker.TrackPageView("MainPage", "Main"); } }; }
public static void TrackMeme(HttpContextBase context, string meme) { if (string.Equals(ConfigurationManager.AppSettings["EnableGoogleAnalytics"], "true", StringComparison.OrdinalIgnoreCase) && !IsFromUpboatMe(context.Request.UrlReferrer)) { using (var tracker = new Tracker("UA-41725429-1", "upboat.me")) { tracker.TrackPageView(context, "Generate Meme", context.Request.RawUrl); } } }
static void Main(string[] args) { var tracker = new Tracker("UA-8318723-11", "exceptrack.com"); for (int i = 0; i < 1000; i++) { tracker.TrackPageView("GA API No Session", "GaapiNosession"); tracker.TrackEvent("AAAAA", "MyAction","L1", "V1"); Thread.Sleep(500); } Console.ReadLine(); }
/// <summary> /// Initializes a new instance of the About class. /// </summary> public About() { InitializeComponent(); AnimationContext = LayoutRoot; Loaded += (s, e) => { using (var tracker = new Tracker("UA-29860952-1", "ezweather")) { tracker.TrackPageView("AboutPage", "About"); } }; }
//the UserSession class here is where I store the users session information, including the UserInfo object. //Add to your User Session/Player object : [JsonIgnoreAttribute] public GoogleAnalyticsTracker.AnalyticsSession analyticsSession; public static void LogItem(string pageTitle, string pageURL, UserSession userSession) { //Allow the Analytics to be turned on/off dynamically. if (!Config.AnalyticsEnabled) { return; } try { if (userSession.analyticsSession == null) { userSession.analyticsSession = new AnalyticsSession(); } using (Tracker tracker = new Tracker(Config.AnalyticsKey, Config.AnalyticsSite, userSession.analyticsSession)) { //You can define your own custom variables here. You can either use a unique 'site' per app, //or combine them all in one site, and use a custom variable to pass your app name in. //You can then use Advanced Segments to split your statistics by App tracker.SetCustomVariable(1, "app", Config.AppName); if (userSession.userInfo == null) { tracker.SetCustomVariable(2, "country", "unknown"); tracker.SetCustomVariable(3, "city", "unknown"); tracker.SetCustomVariable(4, "gender", "unknown"); } else { tracker.SetCustomVariable(2, "country", userSession.userInfo.CurrentCountry); tracker.SetCustomVariable(3, "city", userSession.userInfo.CurrentCity); switch (userSession.userInfo.Gender) { case GenderType.Male: tracker.SetCustomVariable(4, "gender", "male"); break; case GenderType.Female: tracker.SetCustomVariable(4, "gender", "female"); break; } } //This uses asynchronous calls, so won't hold up your thread //(was able to leave enabled during a Tradepost Broadcast) tracker.TrackPageView(pageTitle, pageURL); } } catch (Exception e) { log.Error("Error logging analytics", e); } }