Piwik Tracking HTTP API client library for Java

Provides access to the Piwik Tracking HTTP API

License

License

GroupId

GroupId

ch.rasc
ArtifactId

ArtifactId

piwik-tracking
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

Piwik Tracking HTTP API client library for Java
Provides access to the Piwik Tracking HTTP API
Project URL

Project URL

https://github.com/ralscha/piwik-tracking/
Source Code Management

Source Code Management

https://github.com/ralscha/piwik-tracking.git

Download piwik-tracking

How to add to project

<!-- https://jarcasting.com/artifacts/ch.rasc/piwik-tracking/ -->
<dependency>
    <groupId>ch.rasc</groupId>
    <artifactId>piwik-tracking</artifactId>
    <version>1.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/ch.rasc/piwik-tracking/
implementation 'ch.rasc:piwik-tracking:1.0.3'
// https://jarcasting.com/artifacts/ch.rasc/piwik-tracking/
implementation ("ch.rasc:piwik-tracking:1.0.3")
'ch.rasc:piwik-tracking:jar:1.0.3'
<dependency org="ch.rasc" name="piwik-tracking" rev="1.0.3">
  <artifact name="piwik-tracking" type="jar" />
</dependency>
@Grapes(
@Grab(group='ch.rasc', module='piwik-tracking', version='1.0.3')
)
libraryDependencies += "ch.rasc" % "piwik-tracking" % "1.0.3"
[ch.rasc/piwik-tracking "1.0.3"]

Dependencies

compile (3)

Group / Artifact Type Version
com.squareup.okhttp3 : okhttp jar 4.0.1
org.slf4j : slf4j-api jar 1.7.25
org.immutables : value Optional jar 2.7.5

Project Modules

There are no modules declared in this project.

Test Status

piwik-tracking is a library that helps sending tracking requests to a Piwik server from a Java application.

Usage

First create an instance of PiwikConfig to configure the tracker. Mandatory input is the name of the server that hosts Piwik.

  PiwikConfig config = PiwikConfig.builder().addIdSite("1")
	    			.host("mypiwik.host.com")
	    			.authToken("ffffffffffffffffffffff")
		     		.build();

Next create an instance of the PiwikTracker.

  PiwikTracker tracker = new PiwikTracker(config);

The application then has to create an instance of PiwikRequest for every action it wants to send a tracking request to Piwik.

  PiwikRequest request = PiwikRequest.builder().url("http://my.site.com/index.html")
		 		.putParameter(QueryParameter.ACTION_NAME, "anAction")
				.putParameter(QueryParameter.VISITOR_ID, 1)
				.build();

and send the request to Piwik either synchronous (blocking) or asynchronous (non-blocking).

  //send blocking request
  tracker.send(request);

  //send non blocking request
  tracker.sendAsync(request);

When the application sends asynchronous requests the http library (OkHttp) internally starts an ExecutorService. To properly shutdown this service an application can call the shutdown method: tracker.shutdown();

Tracking HTTP API

For more information about the supported request parameters see the official documentation:
https://developer.piwik.org/api-reference/tracking-api

Maven

The library is hosted on the Central Maven Repository

	<dependency>
		<groupId>ch.rasc</groupId>
		<artifactId>piwik-tracking</artifactId>
		<version>1.0.3</version>
	</dependency>

Changelog

1.0.3 - August 12, 2019

  • Issue 1: token_auth shouldn't be mandatory
  • Issue 2: path and scheme cannot be changed
  • Issue 3: Cannot add path wish slashes

1.0.2 - September 26, 2018

  • Replace javax.xml.bind.DatatypeConverter code. This package no longer exists in Java 11

1.0.1 - December 6, 2016

  • Remove unnecessary System.out.println call

1.0.0 - December 3, 2016

  • Initial release

License

Code released under the Apache license.

Versions

Version
1.0.3
1.0.2
1.0.1
1.0.0