How to Track Developer Experience with Docusaurus and Moesif API Analytic

If your product is an API, your customers are typically developers. While many developers aren’t fond of writing documentation for their own applications, they certainly appreciate well written docs for APIs they use. Well written docs can help developers ship their integrations and apps faster instead of getting buried in integration issues and errors.

Good documentation can also be a powerful marketing tool as it go beyond typical reference like pages and show your developer customers the potential use cases of your platform. Developers may find your documentation from search engines when they’re looking for solutions to your customers’ most pressing problems. Aim to have your solutions rank first for SEO.

Good docs are written iteratively by constantly tweaking the developer experience. This required having the right tooling to measure metrics like Time to First Hello World and pinpoint where customers struggle the most. When a customer runs into a 400 error with your API, take a look at what doc pages they were browsing. If they kept running into 400 errors without resolve, maybe those doc pages need to be updated

The Docusaurus Plugin for Moesif API Analytics

Docusaurus is a popular framework for writing and publishing documentation developed by Facebook’s developer team and has a variety of plugins for analytics vendors, search vendors, and more. [Moesif has a plugin for Docusaurus](https://www.moesif.com/docs/client-integration/docusaurus which enables you to track what doc pages are being browsed and track the customer journey. Moesif is designed for API products and thus can track both web activity along with monitor API traffic. This enables you to build advanced funnel reports such as time to first API call.

The SDK automatically collects useful context from a user’s device including any marketing attribution, device type, and location information and stores in the user and/or company profile in Moesif. You can add additional customer properties such as user email and company domain via the identifyUser() and identifyCompany() methods.

Diagram of Moesif API monitoring and Docusaurus architecture

This allows you to integrate Moesif into your docusaurus.config.js with just a few lines of code.

Install it with this command:

$ npm i docusaurus-plugin-moesif

And update your docusaurus.config.js like this:

module.exports = {
  plugins: ["docusaurus-plugin-moesif"],
  themeConfig: {
    moesif: {
      applicationId: "Your Moesif Application Id",
      // Add other Moesif options here.
    },
  },
};

This now sends all views to your docs to Moesif, so you can see which of your docs are popular.

If you want to get deeper insights you can also identify which user is currently browsing which doc, and then link what they viewed to their API request.

window.moesif.identifyUser("12345", {
  email: "john@example.com",
  firstName: "John",
  lastName: "Doe",
  title: "Software Engineer",
  salesInfo: {
    stage: "Customer",
    lifetimeValue: 24000,
    accountOwner: "ceo@example.com",
  },
});

Tracking doc visits and API traffic

Once you have Moesif set up, you can leverage it to track your conversion funnel such as how many developers who viewed your docs actually converted to an active user. Then you can understand your best and worst docs by looking at each conversion rate based on what they browsed.

Using analytics on your docs can also be an excellent way to determine which features potential customers are interested in. This also means you can solve two of your problems at once: delivering solutions to your existing customers and using those solutions to acquire new customers.

The other way to get value from running analytics on your docs is to link up the viewing of a documentation page with your API’s behavior. If you see that a customer read a specific API doc and then later gets errors from your API because they sent the wrong request, it could be that your docs imparted the wrong information. Conversely, if a customer got error responses that vanished after reading the docs, you could conclude that the docs helped them.

In order to do so, you should install a Moesif server integration. An example of how to do this for Node.js is below:

1. Install the SDK

npm install --save moesif-nodejs

2. Initialize the SDK

// 1. Import Modules
const express = require('express');
const app = express();
const moesif = require('moesif-nodejs');

// 2. Set the options, the only required field is applicationId
const moesifMiddleware = moesif({
  applicationId: 'Your Moesif Application Id',

  // This function should return the same id used in the above window.moesif.identifyUser
  identifyUser: function (req, res) {
    return req.user ? req.user.id : undefined;
  },
});

// 3. Enable the Moesif middleware to start logging incoming API Calls
app.use(moesifMiddleware);

The user is used for the function window.moesif.identifyUser in Docusaurus should match the id used in the server integration’s identifyUser method. This ensures Moesif can stitch together correctly.

Keeping track of your docs’ search terms is one of the most important issues, since you can then identify which pieces are missing from your docs and even from your API.

Learn More About Moesif Lower your API monitoring cost with Moesif 14 day free trial. No credit card required. Learn More

Summary

API docs are table stakes in an API SaaS company. Even a mediocre API implementation can be a pleasure to with when the docs are detailed and complete.

If you run analytics on your API docs’ usage, you can get significant insight into your customers’ mindset: what do they want to do with your API, is it possible, are the docs lacking, and is your API lacking. Analytics can extract all of these things from analyzing your docs’ usage alone.

With Moesif you can run analytics on your API and its docs in one place, even linking actions to requests and thus gathering even more insights. Do your customers find the docs related to their errors, and do the docs solve their errors? With the integrated solution you can be sure to always be on top of how your customers use your API product and how you can improve it moving forward.

Track time to first hello world with Moesif Track time to first hello world with Moesif

Track time to first hello world with Moesif

Learn More