Bento

Bento JavaScript SDK Guide

This guide covers integrating Bento's JavaScript SDK for client-side analytics, user tracking, and engagement features.

Additional Resources

Learning Computer Streamline Icon: https://streamlinehq.com
1
Installation

Installation

Add the Bento tracking script to your website:

You can find your Site UUID in your Bento Account Settings.

2
Basic Setup

Basic Setup

Once the script loads, Bento is automatically available via the global window.bento object:

The SDK automatically:

  • Generates unique visitor and visit IDs
  • Tracks the initial page view
  • Handles visitor session management
3
Verification

Verify the integration is working:

Check your browser's developer console for Bento confirmation messages.

Learning Computer Streamline Icon: https://streamlinehq.com

Page View Tracking

Page views are automatically tracked when the script loads. For single-page applications, track navigation manually:

Manual Page View Tracking

SPA Navigation Tracking

User Identification

Connect user actions across sessions by identifying users with their email:

Basic Identification

Dynamic Identification

Event Tracking

Track custom events to understand user behavior and trigger workflows:

Basic Event Tracking

Events with Data

Common Event Examples

Learning Computer Streamline Icon: https://streamlinehq.com

User Tagging

Add tags to segment users and trigger targeted campaigns:

Single Tag

Multiple Tags

Custom Fields

Store additional user data for personalization and segmentation:

Basic Fields

Progressive Profiling

Survey Integration

Bento includes built-in survey functionality for collecting user feedback:

Survey Forms

Add survey forms to your HTML:

Available Survey Types

TypeDescriptionUse Case
popupModal overlay surveyExit intent, feedback
toasterSmall notification surveyQuick polls, ratings
takeoverFull-screen surveyDetailed questionnaires
inlineEmbedded in page contentContent-specific forms
Learning Computer Streamline Icon: https://streamlinehq.com

Core Methods

MethodDescriptionExample
bento.view()Track page viewbento.view()
bento.identify(email)Identify user by emailbento.identify('[email protected]')
bento.track(event, data)Track custom eventbento.track('signup', { plan: 'pro' })
bento.tag(tag)Add tag to userbento.tag('premium_user')
bento.updateFields(fields)Update user fieldsbento.updateFields({ name: 'John' })

Utility Methods

MethodDescriptionExample
bento.getEmail()Get current user emailconst email = bento.getEmail()
bento.getName()Get current user nameconst name = bento.getName()

Survey Methods

MethodDescriptionExample
bento.showSurveyForm(element, id, type)Show survey formbento.showSurveyForm(el, 'survey-1', 'popup')
bento.spamCheck(email)Validate emailbento.spamCheck('[email protected]')

Chat Methods (if enabled)

MethodDescriptionExample
bento.showChat()Enable chatbento.showChat()
bento.hideChat()Hide chatbento.hideChat()
bento.openChat()Open chatbento.openChat()
Learning Computer Streamline Icon: https://streamlinehq.com

Performance

Load Optimization

Event Debouncing

Prevent excessive event tracking:

Data Quality

Email Validation

Error Handling

Privacy

Conditional Tracking

Learning Computer Streamline Icon: https://streamlinehq.com

Common Issues

IssueSolution
Script not loadingVerify Site UUID is correct and script URL is accessible
Events not trackingCheck browser console for errors, ensure window.bento exists
Double trackingRemove duplicate script tags, check for multiple installations
CORS errorsEnsure your domain is whitelisted in Bento settings

Debug Mode

Enable debug logging:

Network Issues

Learning Computer Streamline Icon: https://streamlinehq.com