Browse Source

Fixed title and language/plugins for tracking.

tags/2.0.3
Teknikode 4 years ago
parent
commit
3f497b3de1
2 changed files with 16 additions and 10 deletions
  1. 2
    4
      Teknik/Filters/TrackingFilterAttribute.cs
  2. 14
    6
      Teknik/Helpers/Tracking.cs

+ 2
- 4
Teknik/Filters/TrackingFilterAttribute.cs View File

@@ -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.

+ 14
- 6
Teknik/Helpers/Tracking.cs View File

@@ -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