How to add Appwrite Analytics to your website
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.

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
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.
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.
- In the Appwrite Console, open your project and go to Apps.
- Select Add app.
- Select Web and your framework. Then select Continue.
- Enter a name and your site's hostname, such as
example.com. - Select Register and continue.
Create an analytics property
A property collects the events of one website or app, and each property has its own dashboard.
- Go to Analytics and select Create property.
- Enter a Name, such as
Storefront. - Under Type, keep Web selected.
- Enter your site's Domain, such as
example.com. - 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:
<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:
npm install appwrite
Create src/analytics.ts with one Tracking instance for the site:
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.
Confirm the first visit
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
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:
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.
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
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.
Resources
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.
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.
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.
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.
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.
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.





