AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Configuring Analytics and Feedback Tracking in Mintlify with PostHog and GA4

Caitlin Millman · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Most DevRel and engineering documentation teams treat developer docs like marketing blogs, measuring success by vanity page views and aggregate bounce rates. At 365Finds, our research indicates this approach is fundamentally flawed. In developer portals, a high bounce rate on an API reference page often signals success—a developer found the cURL command, copied the payload, and left to execute it in their terminal. Conversely, high time-on-page frequently signals friction, ambiguity, or broken sample code.

To truly understand developer behavior, diagnose content gaps, and prove the ROI of documentation on commercial API key registrations, teams running Mintlify need a dual-track telemetry stack: Google Analytics 4 (GA4) for macro-level traffic attribution and search engine acquisition, combined with PostHog for micro-level developer journey analysis, session replays, code snippet copy tracking, and zero-match search discovery.

Here is the complete operational guide to configuring and tuning this architecture in Mintlify's modern docs.json specification.


1. Client-Side Telemetry Setup in docs.json

Mintlify provides first-class native integrations for both GA4 and PostHog. You do not need to install NPM packages or wrap client components; configuration lives directly inside your project's root docs.json.

Minimal Production Configuration

Add your GA4 Measurement ID and PostHog project API key under the top-level integrations key in docs.json:

{
  "$schema": "https://mintlify.com/docs.json",
  "name": "Acme API Documentation",
  "theme": "mint",
  "integrations": {
    "ga4": {
      "measurementId": "G-XXXXXXXXXX"
    },
    "posthog": {
      "apiKey": "phc_your_public_project_api_key_here",
      "apiHost": "https://us.i.posthog.com",
      "sessionRecording": true
    },
    "telemetry": {
      "enabled": true
    }
  }
}

Key Parameter Guardrails


2. Authorizing PostHog Session Recordings

Enabling sessionRecording: true in docs.json alone will not populate replays if PostHog rejects incoming recording payloads.

  1. Navigate to your PostHog Project Settings.
  2. Scroll to the Session Recording section.
  3. Under Authorized domains for recordings, add your production documentation domain (e.g., docs.acme.com) as well as any staging custom subdomains.
  4. If you deploy staging previews via Mintlify deployment links, add those domains to the allowlist or record exclusively on production to conserve recording quotas.

365Finds Operational Rule: Always mask sensitive inputs. In developer documentation, developers often paste test API tokens or internal endpoints into Mintlify's interactive API playground. Ensure PostHog's default canvas and password input masking settings are turned on to prevent capturing sandbox credentials in session replays.


3. Activating the Native Page Feedback Widget

Mintlify features a built-in user feedback loop that lives at the footer of each documentation article. Rather than deploying third-party survey modals that disrupt reading flow, Mintlify embeds lightweight thumbs-up and thumbs-down sentiment buttons and contextual rating inputs.

Configuration Workflow

  1. Log into the Mintlify Dashboard (app.mintlify.com).
  2. Go to Settings → General → Feedback.
  3. Toggle the feedback modules your team plans to monitor:
    • Thumbs Rating: Renders binary positive/negative voting at the bottom of every MDX page.
    • Contextual Feedback: Prompts the developer to submit a brief comment detailing why the page was unhelpful or what was missing.
    • Code Snippet Feedback: Allows readers to flag broken or outdated code blocks directly.
  4. Triage Pipeline: Received feedback appears under the Mintlify dashboard's Analytics → Feedback tab. DevRel engineers should treat feedback items as GitHub-style triage tickets, categorizing items into Pending, In Progress, Resolved, or Dismissed.

4. Advanced Telemetry: Code Copying and Search Drops

While the default integrations automatically stream page views, search entries, and API console triggers, technical writers and DevRel leads need visibility into two critical developer milestones:

  1. Code Snippet Copies: Did the reader copy the initialization snippet or SDK cURL request?
  2. Search Drops: What queries yielded zero results, causing developers to abandon the portal?

Mintlify automatically bundles and executes any standard .js script placed in your repository root. Create an analytics.js file alongside docs.json to monitor code clipboard events and zero-result search interactions.

Injecting Custom Event Tracking (analytics.js)

// analytics.js placed at the root of your Mintlify repository
(function () {
  if (typeof window === "undefined") return;

  // Track Code Snippet Copy Events
  document.addEventListener("click", function (event) {
    const copyButton = event.target.closest('button[aria-label*="Copy"], button[data-testid="copy-code-button"]');
    if (!copyButton) return;

    const codeContainer = copyButton.closest("pre") || copyButton.closest('[class*="code-block"]');
    const language = codeContainer ? (codeContainer.getAttribute("data-language") || "unknown") : "unknown";
    const currentPath = window.location.pathname;

    const payload = {
      event: "code_snippet_copied",
      path: currentPath,
      code_language: language,
      timestamp: new Date().toISOString()
    };

    // Forward to PostHog
    if (window.posthog && typeof window.posthog.capture === "function") {
      window.posthog.capture("code_snippet_copied", payload);
    }

    // Forward to Google Analytics 4
    if (typeof window.gtag === "function") {
      window.gtag("event", "code_snippet_copied", payload);
    }
  }, true);
})();

Analyzing Search Drops

Zero-result searches represent high-intent developer demands that your documentation fails to satisfy. You can uncover these through two mechanisms:

  1. Mintlify AI Agent Querying: On paid plans, you can query your documentation data directly via Mintlify's natural language agent in the editor: "What are the top search terms that produced zero page results over the last 30 days?"
  2. PostHog Search Analytics: When readers submit searches, Mintlify emits search query data. By tracking subsequent page navigations within 10 seconds of a search submission, PostHog isolates sessions where the user immediately bounced or repeated modified queries—a primary signal of search frustration.

5. Connecting Docs Reading to API Key Signups (Attribution Pipeline)

The ultimate metric for commercial developer portals is conversion: how many developers who landed on /docs/quickstart successfully registered for a production API key?

The PostHog Data Warehouse Pipeline

On Mintlify Pro and Enterprise plans, teams can link Mintlify directly as a PostHog Data Warehouse Source:

  1. In Mintlify, navigate to Settings → Organization → API Keys.
  2. Generate an Admin API Key (prefixed with mint_).
  3. Note your Project ID from the same page.
  4. In PostHog, navigate to Data Pipelines → Sources → + New Source → Mintlify.
  5. Input the Admin API Key and Project ID.
  6. PostHog will automatically sync the following data tables:
    • views and visitors: Path-level consumption, segmented by human users versus AI scrapers.
    • searches: Aggregate query terms and search click-through counts.
    • feedback: Page ratings and qualitative comments with triage status.
    • assistant_conversations: Interactions with the built-in AI assistant, including resolution status.
flowchart LR
    A["Developer Lands on Docs"] --> B["Reads Quickstart / Copies cURL"]
    B --> C["Client-side PostHog & GA4 Telemetry"]
    B --> D["Clicks Outbound CTA: 'Get API Key'"]
    D --> E["Console / Dashboard Signup App"]
    E --> F["PostHog User Identify (Distinct ID)"]
    C --> G["Mintlify Backend Analytics API"]
    G --> H["PostHog Data Warehouse Sync (mint_)"]
    F & H --> I["Full-Funnel Conversion & Attribution Dashboard"]

Implementing Cross-Domain Attribution

To stitch the anonymous reader on docs.acme.com to the authenticated developer on app.acme.com:


Architecture Summary: GA4 vs. PostHog vs. Mintlify Native

DimensionGoogle Analytics 4 (GA4)PostHog Client & WarehouseMintlify Native Dashboard
Primary ValueMacro traffic volume; SEO landing pages; geo breakdownGranular developer journeys; session replays; copy eventsQuick content triage; thumbs up/down scores; AI chat logs
Setup Mechanismintegrations.ga4 in docs.jsonintegrations.posthog + PostHog Data SourceMintlify Dashboard settings
Identifier / SecretG-XXXXXXXXXX (Public)phc_... (Client Public); mint_... (Admin Private)Internal organization token
Conversion FunnelsHigh-level goal tracking; outbound link clicksEnd-to-end user identification; docs-to-product funnelLimited to documentation boundaries
AI vs Human TrafficBlended (requires custom bot filters)Distinct columns in views and visitors tablesSeparated traffic breakdown

365Finds Recommendation & Verdict

At 365Finds, we firmly advise developer platform teams against relying on either tool in isolation.

Documentation is not marketing collateral; it is an active software interface. Measuring it like software with telemetry and session replays is the fastest way to reduce developer churn.


References