Analytics
Learn how to set up and use various analytics tools in your MkSaaS website
MkSaaS supports multiple analytics tools to track website traffic and user behavior.
Setup
Vercel Analytics
Vercel Analytics provides detailed insights into your website's visitors without compromising user privacy.
- Enable Web Analytics in your Vercel project dashboard >
Analyticstab >Web Analyticssection - Enable in website configuration:
analytics: {
enableVercelAnalytics: true,
}Vercel Speed Insights
Speed Insights helps you monitor and improve your website's performance.
- Enable Speed Insights in your Vercel project dashboard >
Analyticstab >Speed Insightssection - Enable in website configuration:
analytics: {
enableSpeedInsights: true,
}Google Analytics provides website tracking and analytics.
- Create a Google Analytics account and set up a new property
- Get your Measurement ID (starts with "G-")
- Add the environment variable:
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID="G-XXXXXXXXXX"Umami
Umami is a simple, privacy-focused alternative to Google Analytics.
- Create a Umami account at umami.is or self-host
- Create a new website and get your Website ID and script URL
- Add the environment variables:
NEXT_PUBLIC_UMAMI_WEBSITE_ID="YOUR-WEBSITE-ID"
NEXT_PUBLIC_UMAMI_SCRIPT="https://cloud.umami.is/script.js"For self-hosted Umami instances, use your custom script URL instead of the default one.
Plausible
Plausible is a lightweight, open-source, and privacy-friendly analytics tool.
- Create a Plausible account at plausible.io or self-host
- Add your website and get your domain
- Add the environment variables:
NEXT_PUBLIC_PLAUSIBLE_DOMAIN="YOUR-DOMAIN"
NEXT_PUBLIC_PLAUSIBLE_SCRIPT="https://plausible.io/js/script.js"For self-hosted Plausible instances, use your custom script URL instead of the default one.
PostHog
PostHog provides detailed insights into your website's traffic and user behavior.
- Create a PostHog account and a new project
- Get your Project API Key and Host Server Domain
- Add the environment variables:
NEXT_PUBLIC_POSTHOG_KEY="YOUR-PROJECT-KEY"
NEXT_PUBLIC_POSTHOG_HOST="YOUR-HOST"Ahrefs
Ahrefs provides detailed insights into your website's traffic and backlinks.
- Create a Ahrefs account and a new website
- Get your Website ID from Web Analytics
- Add the environment variable:
NEXT_PUBLIC_AHREFS_WEBSITE_ID="YOUR-WEBSITE-ID"OpenPanel
OpenPanel is an open-source product analytics platform.
- Create an OpenPanel account and a new project
- Get your Client ID
- Add the environment variable:
NEXT_PUBLIC_OPENPANEL_CLIENT_ID="YOUR-CLIENT-ID"DataFast
DataFast is a simple, privacy-friendly analytics tool focused on speed and reliability.
- Create a DataFast account and add your website
- Get your Website ID and domain
- Add the environment variables:
NEXT_PUBLIC_DATAFAST_WEBSITE_ID="YOUR-WEBSITE-ID"
NEXT_PUBLIC_DATAFAST_DOMAIN="YOUR-DOMAIN"To enable DataFast revenue tracking, set enableDatafastRevenueTrack: true in src/config/website.tsx.
Clarity
Clarity provides heatmaps and session recordings for understanding user behavior.
- Create a Clarity account and a new project
- Get your Project ID
- Add the environment variable:
NEXT_PUBLIC_CLARITY_PROJECT_ID="YOUR-PROJECT-ID"Seline
Seline focuses on subscription businesses and conversion tracking.
- Create a Seline account and set up your project
- Get your token
- Add the environment variable:
NEXT_PUBLIC_SELINE_TOKEN="YOUR-TOKEN"Extending New Analytics
- Create a new file in
src/analyticsdirectory (e.g.,my-analytics.tsx) - Implement your analytics component:
'use client';
import Script from 'next/script';
export function MyAnalytics() {
if (process.env.NODE_ENV !== 'production') {
return null;
}
const apiKey = process.env.NEXT_PUBLIC_MY_ANALYTICS_API_KEY;
if (!apiKey) {
return null;
}
return (
<Script
strategy="afterInteractive"
src="https://example.com/analytics.js"
data-api-key={apiKey}
/>
);
}- Add it to the
Analyticscomponent insrc/analytics/analytics.tsx:
import { MyAnalytics } from './my-analytics';
export function Analytics() {
// ...existing code
return (
<>
{/* existing analytics components */}
<MyAnalytics />
</>
);
}- Add the environment variable:
NEXT_PUBLIC_MY_ANALYTICS_API_KEY="YOUR-API-KEY"
MkSaaS Docs