DEV Community

Cover image for How i use Splitbee to measure web traffic on my website
Mmontsheng Maoto
Mmontsheng Maoto

Posted on

How i use Splitbee to measure web traffic on my website

Splitbee is a lightweight and easy to use web analytics tool. It allows you to collect stats about your website, such as where visitors came from, how long they stayed, how they found the site and their country.

1. Get started

Heard over to splitbee to create your free account. Sign up for a free account, and add your website on the dashboard.

2. Add Splitbee to your website.

Adding Splitbee to your website is easy. Add the following script tag to the

of your website.
<script async src="https://cdn.splitbee.io/sb.js"></script>
Enter fullscreen mode Exit fullscreen mode

Ensure your script tag has the async or defer attribute.
Navigate to your website, you should now some some stats on your Splitbee dashboard.

Or even better, if you use NPM or Yarn, Splitbee has package called @splitbee/web.

Installation with npm

npm i @splitbee/web
Enter fullscreen mode Exit fullscreen mode

Installation with yarn

yarn add @splitbee/web
Enter fullscreen mode Exit fullscreen mode

Initialize splitbee in your main.js or entry point of your application.

splitbee.init();
Enter fullscreen mode Exit fullscreen mode

3. Event tracking

Splitbee also supports custom events, you can track user actions within your app, such as sign up button click, product purchase/adding to cart.
It is as easy as

splitbee.track("Sign Up")
Enter fullscreen mode Exit fullscreen mode

If you want to add custom data,

splitbee.track('CART', {
  name: 'Added product to cart',
});
Enter fullscreen mode Exit fullscreen mode
splitbee.track('CART', {
  name: 'Removed product from cart',
});
Enter fullscreen mode Exit fullscreen mode

Thank you for reading, for more information, see the Splitbee documentation.

Top comments (0)