npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@digitaloptgroup/analytics

v0.0.1-pre-release.9

Published

Analytics library for Digital Optimization Group's Headless A/B Testing CMS

Downloads

12

Readme

Digital Optimization Group - Javascript Analytics

This library is made to work with Digital Optimization Group's Headless A/B testing CMS. It provides a range of event tracking automatically, plus it provides a public api to allow custom event tracking.

At 15kb gzipped it's lighter than Google Analytics.

What's tracked by this library?

  • a/b test variations actually appearing in a user's viewport (not just assignment)
  • time a variation is in a user's viewport
  • time on site and time on page
  • visibility of the page (is tab visible?)
  • mouse distance
  • total scrolling distance by page
  • scroll depth per page
  • errors
  • arbitrary outcomes set up by the user of this library
  • page views
  • orientation changes (mobile devices)
  • mousedown activity on a variation

All events are placed on a timeline so that outcomes can be properly attributed to variations actually appearing in the viewport. For example, we shouldn't attribute an order that occured before a variation was in the viewport to that variation when running an a/b test.

Usage

npm

npm install --save @digitaloptgroup/analytics

yarn

yarn add @digitaloptgroup/analytics

Initialze

import { initTracker } from "@digitaloptgroup/js-analytics";

const config = {
  apiKey: "your-api-key",
  projectId: "your-project-id",

  // optional advanced configuration
  // see advanced further down this README
  vid: "visitor_id",
  rid: "request_id",
  startTimestamp: "proxy_startTimestamp"
};

const {
  pathChange,
  outcome,
  caughtError,
  getIntersectionObserver
} = initTracker(config);

Track Pageviews

const pathname = "/about-us";
pathChange(pathname);

Track Outcomes

Tracking events with outcome is intended as a means to track any custom user actions that you would like to associate with your a/b test variations.

outcome takes two arguments outcomeName and metadata. The name must be a string. The metadata must be an array containing an arbitrary number of objects with the type signature { key: string, value: string }.

const outcomeName = "addToCart";
const metadata = [
  { key: "sku", value: "product_123" },
  { key: "price", value: "125.99" }
];
outcome(outcomeName, metadata);

Caught Errors

If you would like to report a caught error you may do so with caughtError.

const metadata = [
  { key: "type", value: "auth_failed" },
  { key: "url", value: "/login" }
];
caughtError(metadata);

Observe / Unobserve Variation

initIntersectionObserver provides viewport tracking for a/b test variations. It is intended to be used with Digital Optimization Group's Headless CMS.

Automatically Tracked Events

In addition to the events listed above, this library automatically tracks the following events:

Euclidian Mouse Distance

The library will sample mouse position every 250ms and calculate the euclidean distance from prior x and y coordinates. It will report the total every 3 seconds.

Page Scrolling

The depth and distance of scrolling activity will be reported in 3 second windows.

Orientation Change

Orientation change will be reported for mobile devices.

Rapid Clicking (or Rage Clicking)

If multiple clicks are recorded within a very small pixel range the number of clicks and the underlying innerHTML will be reported.

Time on Page

Time on page events will be emitted in a decreasing interval.

Time on Site

Time on site events will be emitted in a decreasing interval.

Mousedown on variation

Mousedown events occuring on a tracked variation will be reported.