Links

JavaScript

Please make sure to change your API token to `Public Access`in the LogSnag API settings when using the script on a public website.

Usage

Import Library

<script src="https://cdn.logsnag.com/js/1.0.0/ls.js"></script>

Initialize Client

const logsnag = new window.LogSnag({
token: '7f568d735724351757637b1dbf108e5',
project: 'my-saas'
});

Track Event

await logsnag.track({
channel: "payments",
event: "New Subscription",
user_id: "user-123",
icon: "💰",
notify: true,
tags: {
plan: "premium",
cycle: "monthly",
trial: false
}
})

User Properties

await logsnag.identify({
user_id: "user_123",
properties: {
name: "John Doe",
plan: "premium",
}
})

Track Insight

await logsnag.insight.track({
title: "User Count",
value: "100",
icon: "👨",
})

Increment Insight

await logsnag.insight.increment({
title: "User Count",
value: 1,
icon: "👨",
})