Analytics Integration

Learn how to add analytics tracking to your documentation

AkiraDocs supports Google Analytics 4 (GA4) out of the box. This guide will help you set up analytics tracking for your documentation.

Setting up Google Analytics

1. Create a Google Analytics 4 property in your [Google Analytics account](https://analytics.google.com/)
2. Get your Measurement ID (starts with "G-")
3. Add the ID to your `akiradocs.config.json`:

1{
2"analytics": {
3"google": {
4"measurementId": "G-XXXXXXXXXX",
5"enabled": true
6},
7"debug": false
8}
9}

What's Tracked Automatically

  • Page views
  • Navigation between pages
  • Time on page
  • User language preferences
  • Device and browser information

Custom Event Tracking

You can track custom events using the `useAnalytics` hook:

1import { useAnalytics } from '@/hooks/useAnalytics'
2function MyComponent() {
3    const { track } = useAnalytics()
4    const handleClick = () => {
5        track('doc_rating', {
6            rating: 5,
7            page: 'getting-started',
8            helpful: true
9        })
10    }
11    return <button onClick={handleClick}>This was helpful</button>
12}

Debug Mode

Enable debug mode to see analytics events in the console during development:

1{
2"analytics": {
3"debug": true
4}
5}

This provides a complete analytics integration that's easy for users to set up and extend as needed.