diff --git a/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java b/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java
new file mode 100644
index 0000000..8ad76c6
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java
@@ -0,0 +1,141 @@
+package de.ids_mannheim.korap.web.filter;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.api.client.filter.LoggingFilter;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+import com.sun.jersey.spi.container.ContainerRequest;
+import com.sun.jersey.spi.container.ContainerRequestFilter;
+import com.sun.jersey.spi.container.ContainerResponseFilter;
+import com.sun.jersey.spi.container.ResourceFilter;
+import de.ids_mannheim.korap.config.BeanConfiguration;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.interfaces.AuthenticationManagerIface;
+import de.ids_mannheim.korap.user.TokenContext;
+import de.ids_mannheim.korap.user.User;
+import de.ids_mannheim.korap.user.UserSettings;
+import de.ids_mannheim.korap.utils.KustvaktLogger;
+import net.minidev.json.JSONArray;
+import org.slf4j.Logger;
+
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.ext.Provider;
+import java.security.SecureRandom;
+import java.util.*;
+
+/**
+ * @author hanl
+ * @date 13/05/2014
+ */
+@Provider
+public class PiwikFilter implements ContainerRequestFilter, ResourceFilter {
+
+    private WebResource service;
+    //    private static final String SERVICE = "http://localhost:8888";
+    private static final String SERVICE = "http://10.0.10.13";
+    private static Logger jlog = KustvaktLogger.initiate(PiwikFilter.class);
+    public static boolean ENABLED = false;
+    private Map<String, String> customVars;
+    private AuthenticationManagerIface securityController;
+
+    public PiwikFilter() {
+        securityController = BeanConfiguration.getBeans()
+                .getAuthenticationManager();
+        ClientConfig config = new DefaultClientConfig();
+        Client client = Client.create(config);
+        if (jlog.isDebugEnabled())
+            client.addFilter(new LoggingFilter());
+        UriBuilder b = UriBuilder.fromUri(SERVICE);
+        service = client.resource(b.build());
+        this.customVars = new HashMap<>();
+    }
+
+    private void send(ContainerRequest request) {
+        Random random = new SecureRandom();
+        MultivaluedMap<String, String> params = new MultivaluedMapImpl();
+        params.add("idsite", "2");
+        params.add("rec", "1");
+        if (!customVars.isEmpty())
+            params.add("_cvar", translateCustomData());
+        params.add("cip", request.getHeaderValue("Host"));
+        params.add("cookie", "false");
+        params.add("r", String.valueOf(random.nextDouble()));
+        params.add("action_name", request.getRequestUri().toASCIIString());
+
+        Locale l = null;
+        if (request.getAcceptableLanguages() != null)
+            l = request.getAcceptableLanguages().get(0);
+        try {
+            service.path("piwik/piwik.php")
+                    .queryParam("idsite", "2").queryParam("rec", "1")
+                    //todo check for empty container
+                    .queryParam("_cvar", translateCustomData())
+                    .queryParam("cip", request.getHeaderValue("Host"))
+                    .queryParam("cookie", "false")
+                    .queryParam("r", String.valueOf(random.nextDouble()))
+                    .queryParam("action_name",
+                            request.getRequestUri().toASCIIString())
+                    .queryParams(params).accept("text/html")
+                    .header("Host", request.getHeaderValue("Host"))
+                    .header("User-Agent", request.getHeaderValue("User-Agent"))
+                    .acceptLanguage(l).method("GET");
+        }catch (Exception e) {
+            // do nothing if piwik not available!
+        }
+    }
+
+    private String translateCustomData() {
+        final Map<String, List<String>> customVariables = new HashMap<String, List<String>>();
+        int i = 0;
+        for (final Map.Entry<String, String> entry : this.customVars
+                .entrySet()) {
+            i++;
+            final List<String> list = new ArrayList<String>();
+            list.add(entry.getKey());
+            list.add(entry.getValue());
+            customVariables.put(Integer.toString(i), list);
+        }
+
+        final JSONArray json = new JSONArray();
+        json.add(customVariables);
+
+        // remove unnecessary parent square brackets from JSON-string
+        String jsonString = json.toString()
+                .substring(1, json.toString().length() - 1);
+        customVars.clear();
+        return jsonString;
+    }
+
+    @Override
+    public ContainerRequest filter(ContainerRequest request) {
+        if (ENABLED) {
+            try {
+                TokenContext context = (TokenContext) request
+                        .getUserPrincipal();
+                // since this is cached, not very expensive!
+                User user = securityController.getUser(context.getUsername());
+                UserSettings settiings = securityController
+                        .getUserSettings(user);
+                if (settiings.isCollectData())
+                    customVars.put("username", context.getUsername());
+            }catch (KustvaktException | UnsupportedOperationException e) {
+                //do nothing
+            }
+            send(request);
+        }
+        return request;
+    }
+
+    @Override
+    public ContainerRequestFilter getRequestFilter() {
+        return this;
+    }
+
+    @Override
+    public ContainerResponseFilter getResponseFilter() {
+        return null;
+    }
+}
