Instrumenting with NPM Packages

You can choose to instrument your website using our npm packages when instrumenting Koala directly via script tag is not a possibility.

When to use one of the Koala NPM packages?

  • If you want to pin versions of the Koala SDK and not rely on the dynamically generated ones from our CDN
  • When you want to add typescript types for Koala in your project
  • You want to use React hooks in your Koala tracking
  • When you want a tighter integration with your build or type system

Using the generic Browser package

We ship new versions of our SDK to NPM on every release, all releases of the Koala SDK will be available on the @getkoala/browser package on NPM. The browser package includes the most recent bundled version of our SDK.

  1. Install the npm package
$ yarn add @getkoala/browser
  1. Load the Koala SDK
import * as KoalaSDK from '@getkoala/browser'
  1. Load your project
// returns a promise containing the ko namespace object
let ko = null

  // add your project's public key here
  project: 'pk_...'
}).then(koalaSDK => {
  ko = koalaSDK
  1. Use the Koala SDK Once you’ve loaded your project, you should be able to use all methods from the Koala SDK normally on your website
ko.track('Hello from Koala!', eventProperties)
  email: '[email protected]',

We recommend using our inline script tag whenever possible, so you can leverage our fast CDN times and the latest updates, features, and bug fixes whenever they’re available.

Using the React package

Koala also works with Typescript and React. You can install the @getkoala/react package to start using Koala directly in your React app.

You can find more in-depth and up to date guides on our getkoala/react github repo.