Skip to content

bentonow/bento-js-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Bento Javascript/Tracking SDK

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.

Table of contents

Features

  • 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.

Requirements

The Bento JavaScript SDK can be used in any modern web browser.

Bento Account for a valid SITE_UUID.

Getting started

Installation

Add one of the following scripts to your website's header or footer:

Simple Installation

<script src="https://fast.bentonow.com?site_uuid={Site Key}" async defer></script>

Advanced Installation

<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.

Modules

Visitor Identification

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'
    });
})

Custom Fields

Update visitor's custom fields:

bento.updateFields({
    "first_name": "Ash", 
    "last_name": "Ketchum"
});

Event Tracking

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,
      },
    ],
  },
});

Tagging

Add a tag to a visitor:

bento.tag("demo_booked");

Chat Integration

Show or hide chat:

bento.showChat();
bento.hideChat();

Open or close chat window:

bento.openChat();
bento.closeChat();

Utility Functions

Get visitor's email:

const email = bento.getEmail();

Check if an email is spam:

const isSpam = await bento.spamCheck(email);

Subdomain Tracking

Track visitors across subdomains:

bento.trackSubdomains(['example.com', 'test.example.com']);

Things to Know

  1. All events are initially anonymous until a visitor is identified.
  2. The identify method associates all previous and future events from a device with the provided email.
  3. Custom fields should be updated before tracking an event or page-view.
  4. The unique.key in purchase tracking prevents duplicate tracking of the same purchase.
  5. Subdomain tracking is currently in beta and should be thoroughly tested before use in production.

Contributing

We welcome contributions! Please see our contributing guidelines for details on how to submit pull requests, report issues, and suggest improvements.

License

The Bento SDK for javascript is available as open source under the terms of the MIT License.

About

🍱 Bento JS SDK and tracking library

Resources

License

Code of conduct

Stars

6 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors