---
layout: post
title: "How to add Appwrite Analytics to your website"
description: Add Appwrite Analytics to your website with one script tag or the Web SDK. Track pageviews, traffic sources, file downloads, and custom events without cookies.
date: 2026-11-30
cover: /images/blog/add-appwrite-analytics-to-your-website/cover.avif
timeToRead: 6
author: atharva
category: tutorials
featured: false
faqs:
  - question: "How do I add Appwrite Analytics to a website?"
    answer: "Register the site's hostname as a Web app in your Appwrite project and create an analytics property. Then add the tracker script tag to the head of every page. In an app with a build step, install the appwrite package, create a Tracking instance with your property ID, and call start() once when the site loads."
  - question: "Does Appwrite Analytics use cookies?"
    answer: "No. Appwrite Analytics stores nothing on the visitor's device. Each visitor ID is a one-way hash of the IP address, the user agent, the hostname of the page, and a salt that changes every day, so a returning visitor counts once per day."
  - question: "Does Appwrite Analytics track single-page apps?"
    answer: "Yes. The tracker records a pageview each time a visitor moves to another page in a single-page app, so React Router, Next.js, Vue Router, SvelteKit, and similar routers need no extra code."
  - question: "Which events does the Web SDK send automatically?"
    answer: "start() sends pageview, outbound_link, scroll_depth, and engagement_time events. File downloads are opt-in with enableAutoDownloadTracking(), because the file types worth counting depend on the site."
  - question: "How do I track a signup or a purchase?"
    answer: "Call track() on the tracker with an event name, such as signup_completed, and optional props, such as the plan. With the script tag, the tracker is window.__appwriteTracker. Find signup_completed in the Custom events card, and select it to see the visitors who signed up."
  - question: "Does a site on Appwrite Sites need the script tag?"
    answer: "No. Turn on Web analytics in the site's settings, or Enable analytics when creating the site. Appwrite then adds the tracker to every page on the site's production domains and sends its events through the site's own domain."
---

Appwrite Analytics shows how people find and use your website: where visitors come from, which pages they read, and what they do there. It counts visitors without cookies or any storage on their device, and it also shows the bots and AI agents that read your pages.

This tutorial adds Appwrite Analytics to a website with one script tag, or with the Appwrite Web SDK in an app that has a build step. At the end, the site sends pageviews and custom events, and the property's dashboard shows each visit with its source, pages, location, and device.

# Hosting on Appwrite Sites

![The Analytics settings of a site on Appwrite Sites with the Web analytics switch turned on](/images/blog/add-appwrite-analytics-to-your-website/site-analytics.avif)

A site hosted on Appwrite Sites needs no code. Open the site, go to **Settings**, turn on **Web analytics**, and select **Update**. Appwrite adds the tracker to every page on the site's production domains, so skip ahead to [Read the dashboard](#read-the-dashboard).

# Register your website in your project

Appwrite accepts events from a browser only when the page's hostname belongs to a Web app in your project.

1. In the Appwrite Console, open your project and go to **Apps**.
2. Select **Add app**.
3. Select **Web** and your framework. Then select **Continue**.
4. Enter a name and your site's hostname, such as `example.com`.
5. Select **Register and continue**.

# Create an analytics property

![The Create property page with a name, the Web type, a domain, and the Web SDK selected](/images/blog/add-appwrite-analytics-to-your-website/create-property.avif)

A property collects the events of one website or app, and each property has its own dashboard.

1. Go to **Analytics** and select **Create property**.
2. Enter a **Name**, such as `Storefront`.
3. Under **Type**, keep **Web** selected.
4. Enter your site's **Domain**, such as `example.com`.
5. Under **SDK**, keep **Web** selected, and select **Create property**.

The Console opens the install page with your endpoint, project ID, and property ID filled in. Keep it open: it confirms the first event that your site sends.

# Add the tracker script

Add the tracker script to the `<head>` of every page. It loads the Web SDK and starts tracking, so the site needs no other code:

```html
<script defer src="https://sdk.appwrite.io/web/29.4.0/tracker.js"
        data-endpoint="https://<REGION>.cloud.appwrite.io/v1"
        data-project="<PROJECT_ID>"
        data-property="<PROPERTY_ID>"></script>
```

The script records pageviews, including route changes in single-page apps, along with outbound link clicks, scroll depth, and engagement time.

# Or install the Web SDK

In an app with a bundler, such as a Vite or Next.js app, install the Web SDK instead of adding the script tag:

```sh
npm install appwrite
```

Create `src/analytics.ts` with one `Tracking` instance for the site:

```client-web
import { Client, Analytics, Tracking } from 'appwrite';

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>');

export const tracking = new Tracking(new Analytics(client), '<PROPERTY_ID>');
```

Then import `tracking` in the app's entry file, such as `src/main.tsx`, and call `tracking.start()` once. In Next.js and other server-rendered frameworks, call `start()` from a client component that mounts once in the root layout. See [Track a website](/docs/products/analytics/web#start-tracking).

# Confirm the first visit

![The install page in the Console confirms that the first pageview arrived](/images/blog/add-appwrite-analytics-to-your-website/event-received.avif)

Open your site in a browser. Within a few seconds, the install page in the Console shows **Event received** with the first `pageview`. Select **Open dashboard** to see the visit.

# Track custom events

![The Custom events card on the dashboard lists each event name with how many times it was sent](/images/blog/add-appwrite-analytics-to-your-website/custom-events.avif)

Custom events record what people do, such as a signup, a purchase, or an invite. Call `track()` where the action completes, for example after the signup request succeeds. With the script tag, the tracker is `window.__appwriteTracker`, and with the SDK, it's your `tracking` instance:

```client-web
window.__appwriteTracker.track('signup_completed', {
    props: { plan: 'pro', source: 'pricing_page' },
});
```

Select `signup_completed` in the **Custom events** card to see the visitors who signed up. For naming and props, see [Track custom events](/docs/products/analytics/custom-events).

# Track file downloads

Download tracking is off by default, because the file types that matter are different for each site. With the script tag, add `data-track-downloads="true"`. With the SDK, call `tracking.enableAutoDownloadTracking()` after `start()`.

When a visitor selects a link to a file such as a PDF, a ZIP archive, or an installer, the tracker sends a `file_download` event with the file name and extension.

# Read the dashboard

![The Analytics dashboard for a store with unique visitors, visits, pageviews, events, and a chart for the last 30 days](/images/blog/add-appwrite-analytics-to-your-website/dashboard.avif)

Select a metric in the top row, such as **Pageviews**, to plot it on the chart against the previous period. The cards below break the traffic down by source, page, location, and device.

**Humans vs bots** and **AI agents and crawlers** show the automated traffic, such as GPTBot. Select any row to filter the whole dashboard by it, and use **Export** to download the current view as a PDF report or as CSV files.

# Conclusion

That's your first tracked visit and signup. We'd love to see what turns up on your dashboard, so share it or ask a question on [Discord](https://appwrite.io/discord).

# Resources

- [Appwrite Analytics documentation](/docs/products/analytics)
- [Track a website](/docs/products/analytics/web)
- [Track custom events](/docs/products/analytics/custom-events)
- [Serve tracking from your domain](/docs/products/analytics/own-domain)
- [Privacy](/docs/products/analytics/privacy)
