API Reference

Building Your Own Analytics Dashboard with Loop APIs and Webhooks

Introduction: Why Build Your Own Analytics Dashboard?

In today’s data-driven world, having a custom analytics dashboard can be a game-changer for any subscription-based business. But why should you build one in the first place?

When is building an analytics dashboard necessary?
Building a custom analytics dashboard is ideal if you want to combine data from multiple sources, integrate them into one place, and derive deeper insights. For example, you may already have your subscription data in Loop but also want to bring in other sources like your marketing platforms, customer acquisition tools, and sales data to understand your customers better.

If you are only looking to monitor subscription metrics within Loop itself, using Loop’s built-in reports and analytics tools will be sufficient. However, if you want a unified view of the customer journey from acquisition to subscription behavior, customer lifetime value (LTV), retention, churn, and beyond, building a custom analytics dashboard using Loop’s API and webhooks is the right approach.

With a custom dashboard, you can:

  • Integrate data across multiple sources: Combine data from Loop, marketing platforms, customer behavior tools, etc.
  • Track key business metrics: Monitor metrics like LTV, churn rates, subscriber acquisition sources, etc.
  • Have control and flexibility: Customize reports and analytics based on your specific needs.

This article will guide you on how to build your custom analytics dashboard using Loop’s API and webhooks.

Key Metrics to Focus On

When building your own analytics dashboard, the first step is defining the key metrics you want to focus on. Here are some common metrics for subscription-based businesses that you might want to include:

1. Subscriber Acquisition Metrics

  • Subscriber Acquisition Cost (SAC): The total cost of acquiring a new subscriber.
  • Acquisition Channels: Insights into where your subscribers are coming from (e.g., organic, paid ads, referrals, etc.).

2. Subscriber Engagement and Retention

  • Churn Rate: The percentage of subscribers who cancel within a given period.
  • Retention Rate: The percentage of subscribers who continue their subscription after a specific period.
  • Cohort Analysis: Understanding subscriber retention by cohort groups (e.g., subscribers acquired in a particular month).

3. Financial Metrics

  • Monthly Recurring Revenue (MRR): The predictable revenue generated from subscriptions each month.
  • Average Revenue Per User (ARPU): Revenue per subscriber over a given period.
  • Customer Lifetime Value (LTV): The total revenue expected from a customer during their subscription lifetime.

4. Subscription Usage

  • Subscription Plans and Upgrades/Downgrades: The number of subscribers in each plan, and tracking upgrades or downgrades.
  • Trial Conversion Rate: The percentage of trial users who convert to paying customers.

5. Customer Success Metrics

  • Net Promoter Score (NPS): A measure of customer satisfaction and loyalty.
  • Support Tickets: Insights into the number and types of issues customers are facing.

6. Churn Prediction & Retention Insights

By integrating data from other sources, you can build more sophisticated models to predict churn or identify at-risk customers. Loop can feed into these models, providing historical data and behavior patterns.


Which Loop Endpoints to Use?

Once you've defined your metrics, the next step is deciding which Loop API endpoints you will need to call in order to gather the required data.

Common Loop API endpoints for analytics

  1. Subscriber data endpoints:

    • Read subscription details: Fetches subscriber data including subscription status, selling plans, and more. You can filter the data based on the Status, Updated_at, Created_at, etc.
  2. Financial data endpoints:

    • GET /payments: Retrieves payment-related data (transactions, invoices, payment failures).
    • GET /invoices: Retrieves invoices for tracking MRR and ARPU.
  3. Customer order Data:

    • GET /utm_sources: Get data about where your customers are coming from, such as marketing campaigns, referrals, and other channels.
  4. Webhooks for Incremental Data:
    Use webhooks to push new data into your system as events occur. For example:

    • Subscription Created Webhook: To track when a new subscriber joins.
    • Subscription Updated Webhook: To capture when a subscriber changes plans.
    • Order: To keep track of successful and failed payments in real-time.
    • Subscription Canceled Webhook: To monitor cancellations and react in real-time.

Webhooks will allow you to build incremental tables that track only the most recent data, ensuring that you’re not fetching all your data repeatedly, but rather updating it incrementally, reducing strain on your systems.


How to Integrate Webhooks to Build Incremental Tables

While Loop’s APIs give you access to the data you need, webhooks allow you to push real-time updates into your dashboard, making your data more timely and accurate. Here's how to integrate webhooks for incremental updates:

  1. Set up Webhook Endpoints:
    Create an endpoint on your system that can receive incoming webhook data from Loop. This could be a simple REST API that accepts POST requests from Loop.

  2. Subscribe to Relevant Webhooks:
    In the Loop dashboard, select the specific webhooks you want to subscribe to. For example:

    • subscription.created
    • subscription.updated
    • payment.failed
    • invoice.created

    This will allow you to receive data as soon as it happens, ensuring your dashboard always reflects the latest events.

  3. Store the Data in Incremental Tables:
    Set up your database to only store the latest information. This can be done by:

    • Using a timestamp to identify the most recent record.
    • Implementing upsert operations (update or insert) to ensure you don’t duplicate data.
  4. Data Transformation:
    You may want to perform transformations on the data you receive from webhooks. For example, calculating churn rates, LTV, and revenue predictions could be done within your database using scheduled jobs that aggregate this incremental data.