Libraries

Java Script

JavaScript Integrate our JavaScript library into your HTML5 or ActionScript based webapp to get going quickly. This library makes use of asynchronous POST requests through Cross-Origin Resource Sharing (CORS) to make sure Event tracking does not block any of your business logic.

  1. Grab the Katana JavaScript library from: https://bitbucket.org/ninja_metrics/kapi-javascript-lib/src/master/KApi.js
  2. Include the Katana JavaScript library: <script type="text/javascript" src="KApi.js"></script>
  3. Initialize a fresh tracking object: var aKApi = new KApi(yourClientId, yourAppId, yourAppPassword);
  4. Register an Account Id for use later:
var aDateOfBirth = new Date(1980, 8, 22); //September 22 1980
aKApi.loadAccountCreate(new Date(), "cool_dude@example.com", "Free", "en-US", "US", "M", aDateOfBirth, 50.30, "Facebook Mobile");
This equates to saying that a United States, Male, English speaker, born on Sept 22, 1980 registered just now (the new Date() call) and has $50.30 in his account.
  1. Register a Character Id:
aKApi.loadCharacterCreate(new Date(), "wizard", "cool_dude@example.com", "magic", "healer", "T", "fish", "that one guy", 0);
A new character registration happened just now for a character named “that one guy” identified by the string “wizard” of the “fish” race.
If your application does not use the character distinction, then do not initialize characters. Use an empty string anywhere there is an opening for Character Id.
  1. Log a Login Event:
aKApi.logLogin(new Date(), "cool_dude@example.com", "rat", 0, "Facebook Mobile", 0);
cool_dude@example.com logged in just now (the new Date() call) using the Facebook Mobile platform. Based on the first “0” this application does not use shards, and based on the second “0” this app does not use areas.
  1. Log a Logout Event:
aKApi.logLogout(new Date(), "cool_dude@example.com", "rat", 0, "Facebook Mobile", 0);
cool_dude@example.com logged out just now from his Facebook Mobile based session.



Congratulations on getting started!

Note: Any Account Id or Character Id you want to reference must first be initialized; the initialization only has to happen once over the lifetime of any Id. Take a look at the inline method documentation (in KApi.js) or the HTTPS & JSON API for more information on accepted parameter values.

Grab the numeric values for yourClientId and yourAppId from the account management panel, or ask your account manager for help.