Piwik

# open source web analytics

http://piwik.org/

Les articles publiés sur le site

  • Piwik is now using Github issues as our Issue Tracker !

    9 juillet 2014, par Matthieu AubryCommunity, Development

    This is an announcement regarding the Issue Tracker used for the Piwik project. We are excited to announce that Piwik has migrated from Trac to now using Github issues for managing our issues!

    More than 5,400 tickets and 20,000+ comments from 1,000+ users were migrated to Github. Read on for more information.

    Where do I find Piwik Issue Tracker?

    Benefits of using Github Issues for the Piwik project

    There are several advantages of moving to Github issues:

    • Faster and responsive user interface
    • Better cross-project referencing of issues
    • Ability to notify people with the @username functionality
    • No spam
    • Integration with Pull requests and our Git repository

    How do I get notifications for all Piwik tickets?

    To receive notifications for new tickets or new comments in the Piwik project, go to github.com/piwik/piwik, then click the Watch button at the top of the page.

    In Github, watching a repository lets you follow new commits, pull requests, and issues that are created.

    How do I report a bug in Piwik?
    See Submitting a bug report.

    How do I suggest a new feature?
    See Submitting a feature request.

    Next steps

    At Piwik we care a lot about Data ownership. For this reason we need to have an up to date copy of all our tickets and comments out of github.com servers. Our next step will be to create and release as open source a tool to let anyone create a Mirror of their Github issues. See #5299.

    For more information about the Trac->migration, see #5273.

    We look forward to reading your issues on Github!

  • Piwik is now using Github issues as our Issue Tracker !

    9 juillet 2014, par Matthieu AubryCommunity, Development

    This is an announcement regarding the Issue Tracker used for the Piwik project. We are excited to announce that Piwik has migrated from Trac to now using Github issues for managing our issues!

    More than 5,400 tickets and 20,000+ comments from 1,000+ users were migrated to Github. Read on for more information.

    Where do I find Piwik Issue Tracker?

    Benefits of using Github Issues for the Piwik project

    There are several advantages of moving to Github issues:

    • Faster and responsive user interface
    • Better cross-project referencing of issues
    • Ability to notify people with the @username functionality
    • No spam
    • Integration with Pull requests and our Git repository

    How do I get notifications for all Piwik tickets?

    To receive notifications for new tickets or new comments in the Piwik project, go to github.com/piwik/piwik, then click the Watch button at the top of the page.

    In Github, watching a repository lets you follow new commits, pull requests, and issues that are created.

    How do I report a bug in Piwik?
    See Submitting a bug report.

    How do I suggest a new feature?
    See Submitting a feature request.

    Next steps

    At Piwik we care a lot about Data ownership. For this reason we need to have an up to date copy of all our tickets and comments out of github.com servers. Our next step will be to create and release as open source a tool to let anyone create a Mirror of their Github issues. See #5299.

    For more information about the Trac->migration, see #5273.

    We look forward to reading your issues on Github!

  • Track API calls in Node.js with Piwik

    25 juin 2014, par Frederic HembergerCommunity, API, Node.js

    When using Piwik for analytics, sometimes you don’t want to track only your website’s visitors. Especially as modern web services usually offer RESTful APIs, why not use Piwik to track those requests as well? It really gives you a more accurate view on how users interact with your services: In which ways do your clients use your APIs compared to your website? Which of your services are used the most? And what kind of tools are consuming your API?

    If you’re using Node.js as your application platform, you can use piwik-tracker. It’s a lightweight wrapper for Piwik’s own Tracking HTTP API, which helps you tracking your requests.

    First, start with installing piwik-tracker as a dependency for your project:

    npm install piwik-tracker --save
    

    Then create a new tracking instance with your Piwik URL and the site ID of the project you want to track. As Piwik requires a fully qualified URL for analytics, add it in front of the actual request URL.

    var PiwikTracker = require('piwik-tracker');
    
    // Initialize with your site ID and Piwik URL
    var piwik = new PiwikTracker(1, 'http://mywebsite.com/piwik.php');
    
    // Piwik works with absolute URLs, so you have to provide protocol and hostname
    var baseUrl = 'http://example.com';
    
    // Track a request URL: 
    piwik.track(baseUrl + req.url);
    

    Of cause you can do more than only tracking simple URLs: All parameters offered by Piwik’s Tracking HTTP API Reference are supported, this also includes custom variables. During Piwik API calls, those are referenced as JSON string, so for better readability, you should use JSON.stringify({}) instead of manual encoding.

    piwik.track({
        // The full request URL
        url: baseUrl + req.url,
    
        // This will be shown as title in your Piwik backend
        action_name: 'API call',
    
        // User agent and language settings of the client
        ua: req.header('User-Agent'),
        lang: req.header('Accept-Language'),
    
        // Custom request variables
        cvar: JSON.stringify({
          '1': ['API version', 'v1'],
          '2': ['HTTP method', req.method]
        })
    });
    

    As you can see, you can pass along arbitrary fields of a Node.js request object like HTTP header fields, status code or request method (GET, POST, PUT, etc.) as well. That should already cover most of your needs.

    But so far, all requests have been tracked with the IP/hostname of your Node.js application. If you also want the API user’s IP to show up in your analytics data, you have to override Piwik’s default setting, which requires your secret Piwik token:

    function getRemoteAddr(req) {
        if (req.ip) return req.ip;
        if (req._remoteAddress) return req._remoteAddress;
        var sock = req.socket;
        if (sock.socket) return sock.socket.remoteAddress;
        return sock.remoteAddress;
    }
    
    piwik.track({
        // …
        token_auth: '<YOUR SECRET API TOKEN>',
        cip: getRemoteAddr(req)
    });
    

    As we have now collected all the values that we wanted to track, we’re basically done. But if you’re using Express or restify for your backend, we can still go one step further and put all of this together into a custom middleware, which makes tracking requests even easier.

    First we start off with the basic code of our new middleware and save it as lib/express-piwik-tracker.js:

    // ./lib/express-piwik-tracker.js
    var PiwikTracker = require('piwik-tracker');
    
    function getRemoteAddr(req) {
        if (req.ip) return req.ip;
        if (req._remoteAddress) return req._remoteAddress;
        var sock = req.socket;
        if (sock.socket) return sock.socket.remoteAddress;
        return sock.remoteAddress;
    }
    
    exports = module.exports = function analytics(options) {
        var piwik = new PiwikTracker(options.siteId, options.piwikUrl);
    
        return function track(req, res, next) {
            piwik.track({
                url: options.baseUrl + req.url,
                action_name: 'API call',
                ua: req.header('User-Agent'),
                lang: req.header('Accept-Language'),
                cvar: JSON.stringify({
                  '1': ['API version', 'v1'],
                  '2': ['HTTP method', req.method]
                }),
                token_auth: options.piwikToken,
                cip: getRemoteAddr(req)
    
            });
            next();
        }
    }
    

    Now to use it in our application, we initialize it in our main app.js file:

    // app.js
    var express      = require('express'),
        piwikTracker = require('./lib/express-piwik-tracker.js'),
        app          = express();
    
    // This tracks ALL requests to your Express application
    app.use(piwikTracker({
        siteId    : 1,
        piwikUrl  : 'http://mywebsite.com/piwik.php',
        baseUrl   : 'http://example.com',
        piwikToken: '<YOUR SECRET API TOKEN>'
    }));
    

    This will now track each request going to every URL of your API. If you want to limit tracking to a certain path, you can also attach it to a single route instead:

    var tracker = piwikTracker({
        siteId    : 1,
        piwikUrl  : 'http://mywebsite.com/piwik.php',
        baseUrl   : 'http://example.com',
        piwikToken: '<YOUR SECRET API TOKEN>'
    });
    
    router.get('/only/track/me', tracker, function(req, res) {
        // Your code that handles the route and responds to the request
    });
    

    And that’s everything you need to track your API users alongside your regular website users.

  • Track API calls in Node.js with Piwik

    25 juin 2014, par Frederic HembergerCommunity, API, Node.js

    When using Piwik for analytics, sometimes you don’t want to track only your website’s visitors. Especially as modern web services usually offer RESTful APIs, why not use Piwik to track those requests as well? It really gives you a more accurate view on how users interact with your services: In which ways do your clients use your APIs compared to your website? Which of your services are used the most? And what kind of tools are consuming your API?

    If you’re using Node.js as your application platform, you can use piwik-tracker. It’s a lightweight wrapper for Piwik’s own Tracking HTTP API, which helps you tracking your requests.

    First, start with installing piwik-tracker as a dependency for your project:

    npm install piwik-tracker --save
    

    Then create a new tracking instance with your Piwik URL and the site ID of the project you want to track. As Piwik requires a fully qualified URL for analytics, add it in front of the actual request URL.

    var PiwikTracker = require('piwik-tracker');
    
    // Initialize with your site ID and Piwik URL
    var piwik = new PiwikTracker(1, 'http://mywebsite.com/piwik.php');
    
    // Piwik works with absolute URLs, so you have to provide protocol and hostname
    var baseUrl = 'http://example.com';
    
    // Track a request URL: 
    piwik.track(baseUrl + req.url);
    

    Of cause you can do more than only tracking simple URLs: All parameters offered by Piwik’s Tracking HTTP API Reference are supported, this also includes custom variables. During Piwik API calls, those are referenced as JSON string, so for better readability, you should use JSON.stringify({}) instead of manual encoding.

    piwik.track({
        // The full request URL
        url: baseUrl + req.url,
    
        // This will be shown as title in your Piwik backend
        action_name: 'API call',
    
        // User agent and language settings of the client
        ua: req.header('User-Agent'),
        lang: req.header('Accept-Language'),
    
        // Custom request variables
        cvar: JSON.stringify({
          '1': ['API version', 'v1'],
          '2': ['HTTP method', req.method]
        })
    });
    

    As you can see, you can pass along arbitrary fields of a Node.js request object like HTTP header fields, status code or request method (GET, POST, PUT, etc.) as well. That should already cover most of your needs.

    But so far, all requests have been tracked with the IP/hostname of your Node.js application. If you also want the API user’s IP to show up in your analytics data, you have to override Piwik’s default setting, which requires your secret Piwik token:

    function getRemoteAddr(req) {
        if (req.ip) return req.ip;
        if (req._remoteAddress) return req._remoteAddress;
        var sock = req.socket;
        if (sock.socket) return sock.socket.remoteAddress;
        return sock.remoteAddress;
    }
    
    piwik.track({
        // …
        token_auth: '<YOUR SECRET API TOKEN>',
        cip: getRemoteAddr(req)
    });
    

    As we have now collected all the values that we wanted to track, we’re basically done. But if you’re using Express or restify for your backend, we can still go one step further and put all of this together into a custom middleware, which makes tracking requests even easier.

    First we start off with the basic code of our new middleware and save it as lib/express-piwik-tracker.js:

    // ./lib/express-piwik-tracker.js
    var PiwikTracker = require('piwik-tracker');
    
    function getRemoteAddr(req) {
        if (req.ip) return req.ip;
        if (req._remoteAddress) return req._remoteAddress;
        var sock = req.socket;
        if (sock.socket) return sock.socket.remoteAddress;
        return sock.remoteAddress;
    }
    
    exports = module.exports = function analytics(options) {
        var piwik = new PiwikTracker(options.siteId, options.piwikUrl);
    
        return function track(req, res, next) {
            piwik.track({
                url: options.baseUrl + req.url,
                action_name: 'API call',
                ua: req.header('User-Agent'),
                lang: req.header('Accept-Language'),
                cvar: JSON.stringify({
                  '1': ['API version', 'v1'],
                  '2': ['HTTP method', req.method]
                }),
                token_auth: options.piwikToken,
                cip: getRemoteAddr(req)
    
            });
            next();
        }
    }
    

    Now to use it in our application, we initialize it in our main app.js file:

    // app.js
    var express      = require('express'),
        piwikTracker = require('./lib/express-piwik-tracker.js'),
        app          = express();
    
    // This tracks ALL requests to your Express application
    app.use(piwikTracker({
        siteId    : 1,
        piwikUrl  : 'http://mywebsite.com/piwik.php',
        baseUrl   : 'http://example.com',
        piwikToken: '<YOUR SECRET API TOKEN>'
    }));
    

    This will now track each request going to every URL of your API. If you want to limit tracking to a certain path, you can also attach it to a single route instead:

    var tracker = piwikTracker({
        siteId    : 1,
        piwikUrl  : 'http://mywebsite.com/piwik.php',
        baseUrl   : 'http://example.com',
        piwikToken: '<YOUR SECRET API TOKEN>'
    });
    
    router.get('/only/track/me', tracker, function(req, res) {
        // Your code that handles the route and responds to the request
    });
    

    And that’s everything you need to track your API users alongside your regular website users.

  • Help us Reset The Net today on June 5th

    5 juin 2014, par Piwik Core TeamCommunity, Meta

    This blog post explains why the Piwik project is joining ResetTheNet online protest and how you can help make a difference against mass surveillance. It also includes an infographic and links to useful resources which may be of interest to you.

    Snowden revelations, a year ago today

    On June 5, 2013 the Guardian newspaper published the first of Edward Snowden’s astounding revelations. It was the first of a continuous stream of stories that pointed out what we’ve suspected for a long time: that the world’s digital communications are being continuously spied upon by nation states with precious little oversight.

    Unfortunately, mass surveillance is affecting the internet heavily. The Internet is a powerful force that can promote democracy, innovation, and creativity, but it’s being subverted as a tool for government spying. That is why Piwik has decided to join Reset The Net.

    June 5, 2014 marks a new year: a year that will not just be about listening to the inside story of mass surveillance, but a new year of fighting back!

    How do I protect myself and others?

    Reset the Net is asking everyone to help by installing free software tools that are designed to protect your privacy on a computer or a mobile device.

    Reset the Net is also calling on websites and developers to add surveillance resistant features such as HTTPS and forward secrecy.

    Participate in ResetTheNet online protest

    Have you got your own website, blog or tumblr? Maybe you can show the Internet Defense League’s “Cat Signal!” on your website.Get the code now to run the Reset the Net splash screen or banner to help make privacy viral on June 5th.

    Message from Edward Snowden

    Evan from FFTF sent us this message from Edward Snowden and we thought we would share it with you:

    One year ago, we learned that the internet is under surveillance, and our activities are being monitored to create permanent records of our private lives — no matter how innocent or ordinary those lives might be.

    Today, we can begin the work of effectively shutting down the collection of our online communications, even if the US Congress fails to do the same. That’s why I’m asking you to join me on June 5th for Reset the Net, when people and companies all over the world will come together to implement the technological solutions that can put an end to the mass surveillance programs of any government. This is the beginning of a moment where we the people begin to protect our universal human rights with the laws of nature rather than the laws of nations.

    We have the technology, and adopting encryption is the first effective step that everyone can take to end mass surveillance. That’s why I am excited for Reset the Net — it will mark the moment when we turn political expression into practical action, and protect ourselves on a large scale.

    Join us on June 5th, and don’t ask for your privacy. Take it back.

    – Message by Edward Snowden

    ResetTheNet privacy pack infographic

    Additional Resources

    Configure Piwik for Security and Privacy

    More info