What makes Piwik a fantastic Web Analytics tool is its support for open APIs. Piwik allows you to access all of its data points and track users using standard APIs. The reference documentation is found here : http://piwik.org/docs/analytics-api.

Piwik ships with a PHP API client to interact with its APIs. Developers around the world have made available API clients in many languages including : Ruby (https://github.com/piwik/piwik-ruby-api & https://github.com/piwik/piwik-ruby-tracking), Java (https://github.com/piwik/piwik-java-tracking) and Python (https://github.com/piwik/piwik-python-api).

Today we announce the availability of the C# Tracking and Analytics API clients (https://github.com/piwik/piwik-dotnet-tracker & https://github.com/piwik/piwik-dotnet-api). They are fully tested and work with Piwik 1.5. By hosting it on GitHub we have high hopes the community will contribute to its development and bring it up to speed.

With these API clients, it is now possible to track users and access Piwik data points in any .NET application. Here are a couple of usage examples :

Page View Tracking

PiwikTracker piwikTracker = new PiwikTracker(1);
HttpWebResponse response = piwikTracker.doTrackPageView("Document title of current page view");

Goal Tracking

PiwikTracker piwikTracker = new PiwikTracker(1);
HttpWebResponse response = piwikTracker.doTrackGoal(1, 42.69F);

Add New Site

SitesManager siteManager = new SitesManager();
siteManager.setTokenAuth("TOKEN_AUTH");
string[] urls = { "http://brandNew", "http://shinyNew" };
string[] excludedIps = { "123.123.13.1", "212.21.11.2" };
string[] excludedQueryParameters = { "key1", "key2" };
int newSiteId = siteManager.addSite(
  "Brand New Site", 
  urls, 
  true, 
  excludedIps, 
  excludedQueryParameters, 
  "UTC-4", 
  "USD", 
  "group2", 
  new DateTime(2011, 01, 10)
);

Browsers Report

UserSettings userSettings = new UserSettings();
userSettings.setTokenAuth("TOKEN_AUTH");
ArrayList results = (ArrayList) userSettings.getBrowser(1, PiwikPeriod.MONTH, MagicDate.YESTERDAY);
System.Console.WriteLine(results.Count + " results found");
// Loop over each browser name (ie. LABEL)
foreach (Hashtable result in results)
 {
  // Display browser stats
  System.Console.WriteLine(
   result[UserSettings.LABEL] + " " +
   result[UserSettings.NB_UNIQ_VISITORS] + " " +
   result[UserSettings.NB_VISITS] + " " +
   result[UserSettings.NB_ACTIONS] + " " +
   result[UserSettings.MAX_ACTIONS] + " " +
   result[UserSettings.SUM_VISIT_LENGTH] + " " +
   result[UserSettings.BOUNCE_COUNT] + " " +
   result[UserSettings.NB_VISITS_CONVERTED] + " " +
   result[UserSettings.SUM_DAILY_NB_UNIQ_VISITORS] + " " +
   result[UserSettings.LOGO] + " " +
   result[UserSettings.SHORTLABEL]
  );
}

You can find a great deal of examples at https://github.com/piwik/piwik-dotnet-api/blob/master/Piwik.Analytics.Samples/PiwikAnalyticsSamples.cs and https://github.com/piwik/piwik-dotnet-tracker/blob/master/Piwik.Tracker.Samples/PiwikTrackerSamples.cs

This development is sponsored by www.GoDataFeed.com.

Here is the testimonial of Ro Grosman, CEO ofGDFLogoand  TXTLogo:

“Piwik has been instrumental in streamlining the analytics tracking and reporting for our clients; allowing us to focus on our core products while simultaneously providing a complete analytics package for both e-commerce and m-commerce.  Apart from Piwik’s cost-effectiveness, the platform has a seamless integration process (their C# API rocks!),  and its impressive features and customization options make it an indispensable part of our software. “


Julien Moumné

Julien is a Software Engineer from Paris, France. He has contributed many improvements such as: Piwik Scheduled Email Reports, SMS Reports, Image Graphs reports.