Browse Source

Fixed title and language/plugins for tracking.

master
Teknikode 6 years ago
parent
commit
3f497b3de1
  1. 6
      Teknik/Filters/TrackingFilterAttribute.cs
  2. 20
      Teknik/Helpers/Tracking.cs

6
Teknik/Filters/TrackingFilterAttribute.cs

@ -21,11 +21,9 @@ namespace Teknik.Filters @@ -21,11 +21,9 @@ namespace Teknik.Filters
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
string title = string.Empty;
Page page = filterContext.HttpContext.Handler as Page;
if (page != null)
if (filterContext.Controller.ViewBag != null)
{
title = page.Title;
title = filterContext.Controller.ViewBag.Title;
}
HttpRequestBase request = filterContext.HttpContext.Request;
// Fire and forget. Don't need to wait for it.

20
Teknik/Helpers/Tracking.cs

@ -31,20 +31,28 @@ namespace Teknik.Helpers @@ -31,20 +31,28 @@ namespace Teknik.Helpers
PiwikTracker.URL = config.PiwikConfig.Url;
PiwikTracker tracker = new PiwikTracker(config.PiwikConfig.SiteId);
// Get Request Info
string ipAddress = request.ClientIPFromRequest(true);
tracker.setIp(ipAddress);
tracker.setTokenAuth(config.PiwikConfig.TokenAuth);
tracker.setUrl(request.Url.ToString());
tracker.setUserAgent(request.UserAgent);
// Get browser info
tracker.setResolution(request.Browser.ScreenPixelsWidth, request.Browser.ScreenPixelsHeight);
tracker.setBrowserHasCookies(request.Browser.Cookies);
if (!string.IsNullOrEmpty(request.Headers["Accept-Language"]))
tracker.setBrowserLanguage(request.Headers["Accept-Language"]);
BrowserPlugins plugins = new BrowserPlugins();
plugins.java = request.Browser.JavaApplets;
tracker.setPlugins(plugins);
string ipAddress = request.ClientIPFromRequest(true);
tracker.setIp(ipAddress);
tracker.setTokenAuth(config.PiwikConfig.TokenAuth);
tracker.setUrl(request.Url.ToString());
// Get Referral
if (request.UrlReferrer != null)
tracker.setUrlReferrer(request.UrlReferrer.ToString());
// Send the tracking request
tracker.setRequestTimeout(15);
tracker.doTrackPageView(string.Format("{0}/{1}", sub, title));
}

Loading…
Cancel
Save