The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Tracking.cs 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Web;
  3. using Teknik.Configuration;
  4. using Teknik.Utilities;
  5. namespace Teknik.Piwik
  6. {
  7. public static class Tracking
  8. {
  9. public static void TrackPageView(Config config, string title, string sub, string clientIp, string url, string urlReferrer, string userAgent, int pixelWidth, int pixelHeight, bool hasCookies, string acceptLang, bool hasJava)
  10. {
  11. try
  12. {
  13. if (config.PiwikConfig.Enabled)
  14. {
  15. if (config.DevEnvironment)
  16. {
  17. sub = "dev - " + sub;
  18. }
  19. //PiwikTracker.URL = config.PiwikConfig.Url;
  20. //PiwikTracker tracker = new PiwikTracker(config.PiwikConfig.SiteId, config.PiwikConfig.Url);
  21. //// Set Request Info
  22. //tracker.setIp(clientIp);
  23. //tracker.setTokenAuth(config.PiwikConfig.TokenAuth);
  24. //tracker.setUserAgent(userAgent);
  25. //// Set browser info
  26. //tracker.setResolution(pixelWidth, pixelHeight);
  27. //tracker.setBrowserHasCookies(hasCookies);
  28. //if (!string.IsNullOrEmpty(acceptLang))
  29. // tracker.setBrowserLanguage(acceptLang);
  30. //tracker.setPlugins(new BrowserPlugins {java = hasJava});
  31. //// Get Referral
  32. //if (!string.IsNullOrEmpty(urlReferrer))
  33. // tracker.setUrlReferrer(urlReferrer);
  34. //if (!string.IsNullOrEmpty(url))
  35. // tracker.setUrl(url);
  36. //// Send the tracking request
  37. //tracker.doTrackPageView(string.Format("{0}/{1}", sub, title));
  38. }
  39. }
  40. catch (Exception)
  41. {
  42. }
  43. }
  44. public static void TrackDownload(Config config, string userAgent, string clientIp, string url, string urlReferrer)
  45. {
  46. //TrackAction(config. PiwikTracker.ActionType.download, userAgent, clientIp, url, urlReferrer);
  47. }
  48. public static void TrackLink(Config config, string userAgent, string clientIp, string url, string urlReferrer)
  49. {
  50. //TrackAction(config.PiwikTracker.ActionType.link, userAgent, clientIp, url, urlReferrer);
  51. }
  52. //private static void TrackAction(Config config, PiwikTracker.ActionType type, string userAgent, string clientIp, string url, string urlReferrer)
  53. //{
  54. // try
  55. // {
  56. // if (config.PiwikConfig.Enabled)
  57. // {
  58. // PiwikTracker tracker = new PiwikTracker(config.PiwikConfig.SiteId, config.PiwikConfig.Url);
  59. // tracker.setUserAgent(userAgent);
  60. // tracker.setIp(clientIp);
  61. // tracker.setTokenAuth(config.PiwikConfig.TokenAuth);
  62. // // Get Referral
  63. // if (!string.IsNullOrEmpty(urlReferrer))
  64. // tracker.setUrlReferrer(urlReferrer);
  65. // if (!string.IsNullOrEmpty(url))
  66. // tracker.setUrl(url);
  67. // tracker.doTrackAction(url, type);
  68. // }
  69. // }
  70. // catch (Exception ex)
  71. // {
  72. // }
  73. //}
  74. }
  75. }