Analytics
Saves up to 10 hours

Analytics

How to set up analytics for your SaaS


Table of Contents

Overview

The Analytics Plugin helps you integrate tracking tools in your FastStartup app easily. It supports Simple Analytics, Google Analytics, and Hotjar right out of the box.

Everything is pre-configured to save you time. You only need to add a few environment variables, and the plugin will start tracking data immediately.

It also works with the cookie consent feature. If enabled, it will ask users for permission before loading analytics cookies.

Key Features

  • Supports Simple Analytics, Google Analytics, and Hotjar.
  • Easily enable or disable analytics using environment variables.
  • Pre-configured to work with cookie consent.
  • Already set up in the app's layout.

Use Cases

  • Track how users interact with your app.
  • Understand where your traffic comes from.
  • Get insights into user behavior with Hotjar heatmaps.
  • Measure and improve your product’s performance.

Getting Started

To enable the Analytics Plugin, you need to set up the following environment variables in your .env file:

# Google Analytics
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=your-google-analytics-id

# Hotjar
NEXT_PUBLIC_HOTJAR_ID=your-hotjar-id

# Simple Analytics
NEXT_PUBLIC_SIMPLE_ANALYTICS_ENABLED=true
  • NEXT_PUBLIC_GOOGLE_ANALYTICS_ID enables Google Analytics.
  • NEXT_PUBLIC_HOTJAR_ID enables Hotjar.
  • NEXT_PUBLIC_SIMPLE_ANALYTICS_ENABLED enables Simple Analytics (set to true).

Once these are set, the plugin will automatically include the analytics tracking scripts.

Using the Analytics Component

The Analytics Plugin provides an Analytics component. It’s located at:

@/plugins/analytics

You can include it anywhere in your app. However, it’s already set up in app/layout.tsx, so you don’t need to do anything extra.

API Overview

Environment Variables

VariablePurpose
NEXT_PUBLIC_GOOGLE_ANALYTICS_IDEnables Google Analytics tracking
NEXT_PUBLIC_HOTJAR_IDEnables Hotjar tracking
NEXT_PUBLIC_SIMPLE_ANALYTICS_ENABLEDEnables Simple Analytics (boolean)

Analytics Component

The component can be imported as follows:

import Analytics from "@/plugins/analytics";

<Analytics />;

No props are needed. It automatically reads the environment variables.

Comparison to Alternatives

  • Custom Setup: Manually adding scripts for Google Analytics, Hotjar, or Simple Analytics can take hours. With this plugin, it’s plug-and-play.
  • Other Frameworks: Competing SaaS frameworks often require additional configuration for cookie consent and tracking integration.
  • No-Code Tools: While no-code platforms can simplify tracking, they lack customization. The Analytics Plugin gives you full control over the code and setup.

FAQ

1. How do I disable a specific analytics service?

Remove the corresponding environment variable or set it to an empty value. For example:

NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=

2. What happens if I don’t enable cookie consent?

Cookie consent is enabled by default and if not The Analytics Plugin will not load the tracking scripts. However if you wish to remove the cookie consent, then you should modify the Analytics plugin to work without it.

3. Can I add other analytics tools?

Yes, but you’ll need to customize the Analytics component. This plugin currently supports Simple Analytics, Google Analytics, and Hotjar out of the box.

4. Where is the cookie consent integration?

The Analytics Plugin is connected to the cookie consent feature located at:

@/components/features/cookieConsent

When Google Analytics or Hotjar are enabled, it will ask users for consent before loading the scripts.


That’s it! The Analytics Plugin makes it easy to track data in your FastStartup app while keeping things flexible and user-friendly. If you have any questions, feel free to share them!



Save 1,000+ Hours

By signing up, you agree with our Privacy Policy.

Build, Launch, and Grow Your SaaS

Get everything you need to launch your SaaS and land your first paying user—starting today.