## DEV Community is a community of 636,824 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

# Patterns in Usage Equal Happy Users

Throughout my career I've built various web-apps. These include short life projects (e.g. online brand campaigns) and long life projects (e.g. websites, various SAAS products etc.). Through it all I've noticed one thing...

A happy user is a regular user, and a regular user often exhibits patterns in their usage of a product.

If you can spot patterns in your users' usage then you can often spot your happy users!

Now "why would I want to know which of my users is happy with my product?" I hear you ask!

Well, imagine this, you have a happy user exhibiting a pattern, but suddenly the pattern stops, the user disappears and you're one user down on your user base.

What if you could, spot the patterns, and when they stop? Then you could encourage the user to continue back into their pattern.

But why sit trawling through usage data when you can get AI to spot the patterns for you!

I've built a little service to help people do just that...

https://binarystripes.io

(...oh, and it's serverless!)

Let's consider an example!

## The Company

A coffee chain is interested in seeing whether there are patterns in their customers purchasing habits so that they can autonomously trigger incentives to encourage them to carry on as a regular customer.

## The Customer

Their first customer being analysed is Charlie...

We can represent Charlie’s daily coffee buying habits in binary, one being a day they bought a coffee, zero being a day they did not.

Here's the last 4 weeks of data:

`1,0,1,0,0,0,0,1,0,1,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,0`

## The Analysis

We want to discover if Charlie has a weekly habit of coffee buying...

Charlie buys a coffee on a Monday and a Wednesday every week as we can see from the binary.

We can discover this by asking the algorithm to calculate patterns with intervals of 7.

We send Charlie’s data up to the API with the instructions to interval at 7...

The resulting JSON is returned...

```[{ start: 0, // The index the pattern starts end: 21, // The index the pattern ends pattern: [1, 0, 1, 0, 0, 0, 0], // The pattern trailingPattern: [1, 0, 0, 0, 0, 0, 0], // Binary found when the pattern ceased count: 3, // The length of the pattern }]```

We can clearly see that there is one pattern in Charlie’s weekly coffee buying!

## The Reaction

But oh no! It looks like Charlie's coffee buying habit changed after 3 weeks.

The algorithm has told us when it changed and we can see from the trailing pattern that Charlie did not return on Wednesday for their second coffee of the week.

In Charlie's case we can now send them an email or show them a subtle advert saying "We missed you last Wednesday! Have 20% off your coffee next Wednesday!"

Powerful stuff eh?

So you don't run a coffee chain? Why not apply this technique to your web app, or mobile app. Instead of buying a coffee maybe they're logging in, or using a specific part of your service or website!

The possibilities are endless!

## Discussion (1)

George Francis

Super cool! I'll definitely give this a try as soon as I have a good project for it 👀