Tip
Need help? Join our Discord or email jesse@bentonow.com for personalized support.
The Bento JavaScript SDK makes it quick and easy to build an excellent analytics experience in your web application. We provide powerful and customizable APIs that can be used out-of-the-box to track your users' behavior, manage subscribers, and integrate chat functionality. We also expose low-level APIs so that you can build fully custom experiences.
Get started with our π integration guides, or π browse the SDK reference.
- Simple event tracking: We make it easy for you to track user events and behavior in your application.
- Visitor identification: Identify your visitors to associate events with specific users.
- Custom fields: Track and update custom fields for your visitors to store additional data.
- Purchase tracking: Monitor customer purchases and calculate lifetime value (LTV) for your subscribers.
- Chat integration: Easily integrate and control Bento's chat functionality in your application.
- Spam checking: Validate email addresses to ensure data quality.
- Subdomain tracking: Track visitors across multiple subdomains of your website.
The Bento JavaScript SDK can be used in any modern web browser.
Bento Account for a valid SITE_UUID.
Add one of the following scripts to your website's header or footer:
<script src="https://fast.bentonow.com?site_uuid={Site Key}" async defer></script><script src="https://app.bentonow.com/{Site Key}.js" async defer></script>
<script>
window.addEventListener("bento:ready", function () {
if (typeof(bento$) != 'undefined') {
bento$(function() {
bento.view();
});
}
})
</script>Replace {Site Key} with your actual Bento site key.
Identify a visitor:
bento.identify("user@example.com");Identify a user for chat only:
window.addEventListener('bentochat:ready', function() {
window.$bentoChat.setUser('user123', {
email: 'user@example.com',
name: 'Jane Doe',
phone_number: '1234567890'
});
})Update visitor's custom fields:
bento.updateFields({
"first_name": "Ash",
"last_name": "Ketchum"
});Track a custom event:
bento.track("optin", {"organisation_name": "Team Rocket"});Track a purchase:
bento.track("purchase", {
unique: {
key: "INV1234",
},
value: {
currency: "USD",
amount: 1000,
},
cart: {
items: [
{
product_name: "Product 1",
product_id: "1234",
quantity: 1,
price: 1000,
},
],
},
});Add a tag to a visitor:
bento.tag("demo_booked");Show or hide chat:
bento.showChat();
bento.hideChat();Open or close chat window:
bento.openChat();
bento.closeChat();Get visitor's email:
const email = bento.getEmail();Check if an email is spam:
const isSpam = await bento.spamCheck(email);Track visitors across subdomains:
bento.trackSubdomains(['example.com', 'test.example.com']);- All events are initially anonymous until a visitor is identified.
- The
identifymethod associates all previous and future events from a device with the provided email. - Custom fields should be updated before tracking an event or page-view.
- The
unique.keyin purchase tracking prevents duplicate tracking of the same purchase. - Subdomain tracking is currently in beta and should be thoroughly tested before use in production.
We welcome contributions! Please see our contributing guidelines for details on how to submit pull requests, report issues, and suggest improvements.
The Bento SDK for javascript is available as open source under the terms of the MIT License.
