API Specifications

The KISSmetrics API is very simple. You request a URL from our tracking servers that contains various parameters explained below.

Note: All parameters must be properly URL-escaped (such as replacing spaces with + or %20). Most programming languages provide libraries to do this for you.

API URL

You must make your requests against trk.kissmetrics.com using GET. Both HTTP and HTTPS are supported.

Recording events

To record an event you must make a request to our tracking API with the path /e. There are three additional required parameters:

You can, like the other KISSmetrics APIs record any other arbitrary properties that you might want. For example you might include the name of the e-mail variation if you are split testing different e-mail messages. See below for more information on properties.

To record that the user bob did the event Signup and his gender was male you would request the URL:

http://trk.kissmetrics.com/e?_p=bob&_n=Signup&gender=male&_k=YOUR_KEY

Setting Properties

Any additional URL parameter besides the required parameters listed above are automatically recorded as properties. You can set properties on a person without recording an event by making a request to /s. You will need to include:

To set the property Payment Plan to Pro for the user sally you would request the URL:

http://trk.kissmetrics.com/s?_p=sally&Payment+Plan=Pro&_k=YOUR_KEY

You can pass in more than one property at a time also:

http://trk.kissmetrics.com/s?_p=sally&size=small&color=black&_k=YOUR_KEY

Property names are limited to 255 chars and all commas (,), and colons (:) will automatically be changed to spaces (KISSmetrics will convert foo:bar,baz to foo bar baz). Property values are limited to 8 KB of data in theory, but in practice are usually restricted to much shorter values due to maximum URL lengths. KISSmetrics does not alter the values you pass in in any way.

So if you are recording an event use /e, but if you just want to set properties without recording an event, use /s.

Aliasing Users

In some cases a user may have more than one identity. For example if a person comes to your site without signing in you may set a cookie with a unique identifier. You might then use this anonymous identity to track all their activity before signing in. Then later when they sign in you’ll have their username (a named identity) which you might start to use after they sign in. If you want to tie the activity from before they signed in to the activity after they signed in you will have to tell KISSmetrics to treat the two identities as aliases of each other. You can do this by making a request to /a with the following parameters:

So if you want to treat the person bob the same as bob@bob.com you could make a request to:

http://trk.kissmetrics.com/a?_p=bob&_n=bob@bob.com&_k=YOUR_KEY

KISSmetrics will tie together the two records and will treat the identities bob and bob@bob.com as the same person. It’s OK to call this more than once with the same pair of identities. It’s also OK if a person has more than one alias. Also, which identity you use for _p and which one you use for _n are not important (either order works the same).

Note: The KISSmetrics Javascript API takes care of all of this stuff for you automatically. You should only need to call _kmq.push('identify', some_identity) and the Javascript API takes care of aliasing and all of the other bits. However, if you are not using the Javascript API you may need to use this functionality.

Failed HTTP Requests

Our language-specific APIs often have mechanisms to retry event requests when they do not successfully go through on the first request. Consider implementing such a system if you plan to send us batch amounts of events through a direct HTTP request to trk.kissmetrics.com.


Filed under APIs

Search


Learn more about KISSmetrics

Get started now