Documentation.

Installation

When creating a new project, you'll receive a unique project code in the UUIDv4 format.

Example code:

AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE

Browser tracking

To track browser views, embed the Yardstick javascript on pages you'd like to track.

<script type="text/javascript" src="https://cdn.yardstick.dev/yardstick.js"></script>
<script type="text/javascript">
    yardstick.init({projectCode: 'YOUR-CODE-HERE'});
    yardstick.track('pageview');
</script>

Event tracking

With the above javascript embedded, you can also track custom events, such as button clicks, signups or purchases.

To track an event, trigger the following javascript:

yardstick.track(event-name, metadata)

Here's some more practical examples:

yardstick.track('login')
yardstick.track('logout')
yardstick.track('start-free-trial')
yardstick.track('upgraded', {plan: 'pro'})

User profiles

If you'd like to associate views and events with a given user, you can "identify" them. Any existing views and events as well as new ones will be associated with this profile.

yardstick.identify(id, alias, metadata)

Here's a practical example:

yardstick.identify(8, 'user@example.com', {status: 'trialing'})