Content & Social

A Clappy Clicky Thingy for Your Blog ... Without Servers

Managing state is a pain for use cases big or small. Here's a super simple example illustrating how Sumatra makes state management a whole lot easier.

Content & Social

A Clappy Clicky Thingy for Your Blog ... Without Servers

Managing state is a pain for use cases big or small. Here's a super simple example illustrating how Sumatra makes state management a whole lot easier.

Content & Social

A Clappy Clicky Thingy for Your Blog ... Without Servers

Managing state is a pain for use cases big or small. Here's a super simple example illustrating how Sumatra makes state management a whole lot easier.

Problem

Count "likes" on your blog?

As a blogger, it would be nice to add a "like" counter to your articles to showcase engagement.

Solution

Ugh, the infrastructure!

You start thinking: I'm going to need a server. Worse, I'm going to need a database! 😳

Result

Let Sumatra handle it

Implement your simple, stateful service in low code with no infrastructure to manage.

Problem

Count "likes" on your blog?

As a blogger, it would be nice to add a "like" counter to your articles to showcase engagement.

Solution

Ugh, the infrastructure!

You start thinking: I'm going to need a server. Worse, I'm going to need a database! 😳

Result

Let Sumatra handle it

Implement your simple, stateful service in low code with no infrastructure to manage.

Problem

Count "likes" on your blog?

As a blogger, it would be nice to add a "like" counter to your articles to showcase engagement.

Solution

Ugh, the infrastructure!

You start thinking: I'm going to need a server. Worse, I'm going to need a database! 😳

Result

Let Sumatra handle it

Implement your simple, stateful service in low code with no infrastructure to manage.

Set Up a Stateful Service in Under 5 Minutes

Set Up a Stateful Service in Under 5 Minutes

Implementing a click tracker with Sumatra is as easy as pasting a few lines of code into the Sumatra Editor and adding a couple of Javascript snippets to your web site.

Implementing a click tracker with Sumatra is as easy as pasting a few lines of code into the Sumatra Editor and adding a couple of Javascript snippets to your web site.

1. Define your service in 6 lines of code

1. Define your service in 6 lines of code

To configure the service, simply paste the following snippet into the Sumatra Editor and click "Apply".

These few lines of Scowl code define stateful aggregates to count clicks and make them available to query in real time.

To configure the service, simply paste the following snippet into the Sumatra Editor and click "Apply".

These few lines of Scowl code define stateful aggregates to count clicks and make them available to query in real time.

event click
path := $.path as string
clicks := Count(by path)                    

event pageload
path := $.path as string
clicks := Latest<click>(clicks by path)

2. Send Events to Sumatra

2. Send Events to Sumatra

On page load, use Sumatra's web SDK to send a query and receive the click count:

On page load, use Sumatra's web SDK to send a query and receive the click count:

sumatra.enrich('pageload', {
  path: window.location.pathname
})
.then((features) => {
  setCounter(features.clicks)
})

On click, track the event in Sumatra and fetch the result to update in real time:

On click, track the event in Sumatra and fetch the result to update in real time:

sumatra.enrich('click', {
  path: window.location.pathname
})
.then((features) => {
  setCounter(features.clicks)
})

3. There is no "Step 3"

3. There is no "Step 3"

You did it! That's the end-to-end process for deploying your first real-time, scalable, stateful service with Sumatra.

Give yourself a round of applause!

You did it! That's the end-to-end process for deploying your first real-time, scalable, stateful service with Sumatra.

Give yourself a round of applause!

Endless possibilities

Endless possibilities

Sumatra is a powerful platform, capable of building sophisticated, large-scale decisioning solutions. Yet even to the casual blogger, simple use cases like this one deliver immediate value and open up a whole world of possibilities:

  • Only count unique sessions

  • Filter out bots

  • Prompt a user to subscribe after they like 3 articles

  • ...and more!

To try this recipe, get yourself a Sumatra account. It's free.

Sumatra is a powerful platform, capable of building sophisticated, large-scale decisioning solutions. Yet even to the casual blogger, simple use cases like this one deliver immediate value and open up a whole world of possibilities:

  • Only count unique sessions

  • Filter out bots

  • Prompt a user to subscribe after they like 3 articles

  • ...and more!

To try this recipe, get yourself a Sumatra account. It's free.

Get started

Get AI without the gimmicks

Get started

Get AI without the gimmicks

Get started

Get AI without the gimmicks