Start typing to search...
API Reference
Deprecated
@withkoji/analytics
Search

@withkoji/analytics (deprecated)

Warning

This package is deprecated and is included only for backwards compatibility. For new templates, use withkoji-koji-core.html.

The @withkoji/analytics package enables you to track custom events in your Koji templates. For example, track onClick events for the links and buttons in a Koji.

To view the analytics data for your published Koji, click the Koji button and click Analytics. You will see data for your custom events along with a standard set of built-in metrics, which are calculated from the Koji’s access logs.

Tip
Analytics data is processed at frequent intervals throughout the day. If you are testing the custom events in a published template and you don’t see results at first, wait 10 minutes to account for data processing latency, and then check again.

Install

Install the package in the frontend service of your Koji project.

npm install --save @withkoji/analytics

Analytics

Import the package in your application code.

import Analytics from '@withkoji/analytics';

Analytics methods

.track(event, payload)

Generates an analytics event with the specified name and data payload, if applicable.

Parameters

  • eventString, name of the custom event.

  • payloadObject, (Optional) list of custom key-value pairs to save with the event.

Example

Analytics.track('My Custom Event');
Analytics.track('Won game', { score: 120 });