Track cancelled subscriptions in JavaScript

Guide to monitoring and reporting subscription cancellations in your JavaScript app using Operational for timely alerts and analytics.

What is cancellation tracking in JavaScript

Tracking cancelled subscriptions helps you spot churn and follow up with users.

For example, if a user opts out of your service, you can log that event and trigger outreach or analytics updates.

This keeps your revenue data accurate and gives insight into why users leave.

Why track cancellations

  • Understand churn trends over time
  • Automate email campaigns to retain users
  • Improve product based on cancellation reasons

What is Operational and how it works for cancellations

Operational is an open-source event tracking tool that ingests and displays your events in real time.

You can send cancellation events from your JavaScript app and view them on the dashboard.

Operational in action

With Operational you get:

  • Instant alerts when cancellations spike
  • Search and filter on event properties
  • Lightweight SDKs for quick setup

Setting up Operational

  1. Visit app.operational.co and sign up for a free account.
  2. Log in and create a new project in your dashboard.
  3. Copy the API key from the project settings.
  4. Install the SDK in your JavaScript project:
    npm install @operational.co/sdk

Tracking cancelled subscriptions in JavaScript

import Operational from "@operational.co/sdk"

const ops = new Operational("YOUR_API_KEY")

async function reportCancellation(userId, userName, plan) {
  const payload = {
    name: "subscription cancelled",
    avatar: "🚫",
    content: `User ${userName} cancelled subscription for ${plan}`
  }

  await ops.events.ingest(payload)
}

// Example usage
reportCancellation(123, "John Smith", "Premium Plan")

This code imports the Operational SDK, creates a client with your API key, and sends a cancellation event with user details.

Conclusion

Operational makes it easy to track subscription cancellations in your JavaScript app.

It saves you time by handling event ingestion, storage, and real-time updates.

Learn more at https://operational.co or try out the code snippets in the playground:

https://operational.co/playground