MCPcopy Index your code
hub / github.com/AMKohn/bounceback

github.com/AMKohn/bounceback @v1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.0 ↗ · + Follow
7 symbols 12 edges 3 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Bounceback.js

Build Status Test Coverage MIT License devDependency Status

Fast, dependency free exit intent detection

Bounceback provides a simple one-event system that allows you to detect just before a visitor bounces from your site. It works in a fashion similar to the commercial products available, except of course it's open source and doesn't cost $4,000/month.

If you prefer a less hands-on product I'd be more than happy to accept the $4,000 and take care of everything for you.

Features

  • Size: Bounceback is only 1.2 KB
  • 100% test coverage
  • Backwards compatible to IE6
  • Complete mobile support
  • No dependencies, shims or polyfills

Usage

<script src="https://github.com/AMKohn/bounceback/raw/v1.0.0/bounceback.js"></script>
Bounceback.init([options])

Bounceback.init({
  onBounce: function() {
    // Your modal display or similar code goes here
  }
})

Options

maxDisplay

Default: 1

The maximum number of times the dialog may be shown on a page, or 0 for unlimited. Only applicable on desktop browsers.

distance

Default: 100

The minimum distance in pixels from the top of the page to consider triggering for.

method

Default: auto

The bounce detection method.

Options:

auto: Automatically picks a method based on the device type. mouse is used for desktop browsers and history for mobile.

mouse: This detects bounces based on the mouse's direction, velocity and distance from the top of the page.

history: This method uses the HTML5 History APIs (or hashes when in an older browser) to duplicate the page in the history. Then when the visitor clicks to go back Bounceback detects the navigation and shows the dialog. This method is almost foolproof, but could annoy some users. It works best for mobile browsers.

sensitivity

Default: 10

The minimum distance the mouse has to have moved in the last 10 mouse events for onBounce to be triggered.

cookieLife

Default: 365

The cookie (when localStorage isn't available) expiry age, in days.

scrollDelay

Default: 500

The amount of time in milliseconds that bounce events should be ignored for after scrolling, or 0 to disable.

This is necessary for the case when a user is scrolling and their mouse overshoots the page. As soon as scrolling stops a mouseout event is fired incorrectly triggering a bounce event.

Because of this Bounceback waits a small amount of time after the last scroll event before re-enabling bounce detection.

aggressive

Default: false

This controls whether or not the bounce dialog should be shown on every page view or only on the user's first.

storeName

Default: bounceback-visited

The name/key to store the localStorage item (or cookie) under.

onBounce

Default: function() { return Bounceback; }

The handler to call when a bounce has been detected. This accepts no arguments since none are necessary.

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test

While Bounceback has been tested in actual browsers the included tests create a stubbed environment that simulates modern, mobile, and older browsers for simplicity and speed.

License

MIT

If you end up using Bounceback, shoot me a message, I'd love to see it in the wild!

Core symbols most depended-on inside this repo

addEvent
called by 5
lib/bounceback.js
reset
called by 3
test/test.js
core
called by 3
test/test.js
desktop
called by 2
test/test.js
state
called by 0
test/test.js
hash
called by 0
test/test.js
cookie
called by 0
test/test.js

Shape

Function 7

Languages

TypeScript100%

Modules by API surface

test/test.js6 symbols
lib/bounceback.js1 symbols

For agents

$ claude mcp add bounceback \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact