A scala API for KISSmetrics using Dynamic Types.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



scala-kissmetrics is a library for KISSmetrics using dispatch as the HTTP client library and Scala Dynamics to provide a natural way of triggering events at KISSmetrics.


The library is still in alpha stage and currently not used in production. There are tests in place and it should work, but there's no guarantee as of now. The library uses Scala Dynamics and currently requires Scala 2.10. In order to use it in your own projects, you have to to build your own version using sbt. Clone the repository:

git clone https://github.com/kodemaniak/scala-kissmetrics.git

Build using sbt:

cd scala-kissmetrics
sbt test package

This will produce a jar file NOT containing any dependencies. Probably it's more useful to deploy the library to your local Ivy repository and depend on scala-kissmetrics from sbt:

sbt publish-local

And in your project add a dependency:

libraryDependencies += "kv" %% kissmetrics-scala % "0.0.1-SNAPSHOT"

As soon as we have tested the library more thoroughly in our own projects, we will try to get it into one of the public repositories.


KISSmetrics provides three operations via its REST Api, namely defining an alias for a user, triggering an event for a user, and setting properties of a user. The scala-kissmetrics base trait provides these methods in most generic form:

trait BaseService {
  def alias(person1Id: String, person2Id: String)
  def event(personId: String, eventName: String, properties: Map[String, String)
  def properties(personId: String, properties: Map[String, String])

The alias method is simple, we just define that the first person is the same as the second person. The event method triggers an event with the name eventName for the person, and also sets the properties according to the supplied map (which is optional). The properties method only sets the properties according to the supplied map for the person.

Besides the generic methods, scala-kissmetrics emplys Scala Dynamics to provide more concise way of triggering events and setting properties. To trigger an event with name Signup for a person with ID 'abc' and setting the Plan property to 'freemium', we can call the following method:

km.e_Signup_with_Plan("abc", "freemium")

Similarly, we support setting properties as follows. Consider we want to set gender and year of birth for the person above:

km.p_Gender_and_Age("abc", "male", "1977")

The rules are simple. Properties or events containing an underscore can currently not be triggered or set using the dynamic API. Please use the generic methods instead. We might introduce another syntax that allows for this. Underscores are currently interpreted as spaces where appropriate, e.g.


will trigger an event with the name Sent Invitation.

On the e_ methods, properties are separated from the event name by _with_, i.e.


Several properties are separated by _and, both for the event and property methods:

km.p_Gender_and_Age("abc", "male", "1977")

Obviously these methods work well for simple events or setting a few properties. However, you can also call the generic methods as a fallback.

Get involved

If you have any issues, questions, or ideas, please use the issue tracker of github.


This library was developed by Kreuzverweis Solutions GmbH for https://doctivity.io and is published under an Apache 2.0 license.