Documentation

Get started

Everything you need to integrate Analytaics into your site.

Quick Start

Get analytics running on your site in under 60 seconds. Just add a single script tag — that's it.

Prerequisites

  • • An Analytaics account (sign up free)
  • • A website where you can add a script tag

Installation

After creating your account and adding a site, you'll receive a site ID. Add this snippet to your HTML — ideally in the <head> tag:

<script
  defer
  data-site="YOUR_SITE_ID"
  src="https://ingest.analytaics.com/js/tracker.js"
></script>

Replace YOUR_SITE_ID with the ID shown in your dashboard settings.

Framework examples

Next.js (App Router)

// app/layout.tsx
export default function RootLayout({ children }) {
  return (
    <html>
      <head>
        <script
          defer
          data-site="YOUR_SITE_ID"
          src="https://ingest.analytaics.com/js/tracker.js"
        />
      </head>
      <body>{children}</body>
    </html>
  );
}

Astro

<!-- src/layouts/Layout.astro -->
<head>
  <script
    defer
    data-site="YOUR_SITE_ID"
    src="https://ingest.analytaics.com/js/tracker.js"
  ></script>
</head>

Plain HTML

<!DOCTYPE html>
<html>
<head>
  <script
    defer
    data-site="YOUR_SITE_ID"
    src="https://ingest.analytaics.com/js/tracker.js"
  ></script>
</head>
<body>
  <!-- Your content -->
</body>
</html>

Verify Setup

After adding the script, open your site in a browser and check your Analytaics dashboard. You should see yourself as a real-time visitor within seconds.

Troubleshooting

  • No data showing? Check your browser's Network tab for the tracker request. It should load from ingest.analytaics.com.
  • Ad blocker interference? Some ad blockers may block analytics scripts. Try with extensions disabled or set up a custom domain for the tracker.
  • Wrong site ID? Double-check the data-site attribute matches your dashboard settings.

Tracker API

The tracker script accepts configuration via HTML attributes:

AttributeRequiredDescription
data-siteYesYour unique site identifier
data-apiNoCustom API endpoint (advanced)
data-spaNoEnable SPA mode (auto-tracks route changes)
data-hashNoTrack hash-based routing changes

Custom endpoint configuration

If you need to proxy tracking through your own domain (for ad-blocker bypass):

<script
  defer
  data-site="YOUR_SITE_ID"
  data-api="https://your-proxy.com"
  src="https://your-proxy.com/js/tracker.js"
></script>

Custom Events

Track custom interactions like button clicks, form submissions, signups, and purchases using the global analytaics.track() method.

// Basic event
analytaics.track("signup");

// Event with properties
analytaics.track("purchase", {
  plan: "pro",
  amount: 9,
  currency: "USD"
});

// Button click tracking
document.getElementById("cta-btn").addEventListener("click", () => {
  analytaics.track("cta_click", { location: "hero" });
});

Good to know

  • • Event names should be lowercase with underscores
  • • Properties are optional and can be any key-value pairs
  • • Events appear in your dashboard within seconds

Single Page App Support

For SPAs (React, Vue, Next.js, etc.), the tracker automatically detects route changes using the History API. No additional configuration is needed for most frameworks.

<!-- Automatic SPA tracking (default) -->
<script
  defer
  data-site="YOUR_SITE_ID"
  src="https://ingest.analytaics.com/js/tracker.js"
></script>

<!-- For hash-based routing (e.g., /#/page) -->
<script
  defer
  data-site="YOUR_SITE_ID"
  data-hash="true"
  src="https://ingest.analytaics.com/js/tracker.js"
></script>

REST API

Access your analytics data programmatically. Generate an API key from your dashboard settings.

Authentication

# Include your API key in the Authorization header
curl -H "Authorization: Bearer ak_live_your_api_key" \
  https://app.analytaics.com/api/sites/YOUR_SITE_ID/stats

Get site statistics

GET /api/sites/:siteId/stats?period=7d

Response:
{
  "visitors": 2847,
  "pageviews": 8421,
  "bounce_rate": 0.34,
  "avg_duration": 134,
  "pages": [...],
  "referrers": [...],
  "countries": [...]
}

Get real-time data

GET /api/sites/:siteId/realtime

Response:
{
  "active_visitors": 14,
  "active_pages": [
    { "path": "/blog/analytics", "visitors": 5 },
    { "path": "/pricing", "visitors": 3 }
  ]
}

Ready to get started?

Create a free account and start tracking in under a minute.

Sign Up Free