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

probabilitydrive

v1.1.0

Published

Determines where a user is going to navigate to next on a website

Downloads

11

Readme

probabilitydrive.js

Determines where a user is going to navigate to next on a website.

Build Status

Visitors to a website will often make repeated journeys through the same set of pages, or repeat the journeys made by others. On this basis, if we can observe where a user has been, we can make a good guess at where they will go next.

This library will help to analyse which paths have been visited previously and to make probabilistic predictions based on that knowledge. The accuracy of these predictions will depend upon the website in question, and the free will exhibited by its users!

Please note that this library leaves open the choice of how data will be persisted, and therefore offers no default implementation. The examples given below are not sufficient to track a user's journey on their own, as data is only stored in memory and will be lost when the user navigates to another page. See the included example code for a simple way to persist data using the Web Storage API.

Install

server-side with npm:

npm install probabilitydrive

client-side with bower:

bower install probabilitydrive

or just copy the built, or built & minified file, to your project.

Analysis examples

// Create a new instance
var probabilitydrive = new ProbabilityDrive();

// Hook it into your site
window.onload = function() {
    probabilitydrive.observe(window.location.href);
}

// or hook it in using jQuery
$(function() {
    probabilitydrive.observe(window.location.href);
});

// Predict the most likely next paths(s)
probabilitydrive.determine();
[ '/products' ]

// Predict the next paths(s) greater than equal to a given probability threshold
probabilitydrive.probability(0.4);
[ '/products' ]

// Predict the next paths(s) that are in the given probability percentile or above
probabilitydrive.percentile(40);
[ '/products', '/events' ]

Setup examples

// Inform it about your website's path structure using :foo to parameterise them, so that observations along these routes are bundled together
probabilitydrive.routes([
    '/products/:id',
    '/products/:id/info'
]);

// These will now all increase the probability count for '/products/:id'
probabilitydrive.observe('/products/1');
probabilitydrive.observe('/products/2');
probabilitydrive.observe('/products/3');

// and these will both increase the probability count for '/products/:id/info'
probabilitydrive.observe('/products/1/info');
probabilitydrive.observe('/products/2/info');

probabilitydrive.determine();
[ '/products/:id' ]


// Blacklist paths you want to ignore entirely
probabilitydrive.blacklist([
    '/users/:id',
    '/404'
]);

// Ignore paths when making predictions until they have been observed at least a specified number of times
probabilitydrive.setCountThreshold(10);

Utility Examples

// Get the current analysis data
var data = probabilitydrive.getData();

// Set previously retrieved data
probabilitydrive.setData(data);

// i.e. the above are serialise and unserialise - you will need these if you wish to persist data.

// You can chain calls from observe()
probabilitydrive.observe('/example').determine();

Credits

Thanks to...

  • umdjs for the AMD bootstrap