Skip to content

Start with Analytics_

Track your first website visit with Appwrite Analytics. Create a property, add the Web SDK's tracking helper to your site, and see the visit on the dashboard.

2 min read

Raw

In this quick start you create an analytics property, add tracking to a website with the Appwrite Web SDK, and see your first visit on the dashboard.

Add your site to the project

Appwrite accepts events from a browser only when the site's hostname belongs to one of the project's apps. If your site isn't one yet, add it.

  1. Sign in to Appwrite Cloud and open a project.
  2. Open Apps in the sidebar and click Add app.
  3. Choose Web, enter your site's hostname, such as example.com, and finish the wizard.

Add localhost the same way to track your site while you develop.

Create a property

Create property page with a name, a domain, and the Web platform selected
Create property page with a name, a domain, and the Web platform selected

A property collects the events of one site or app.

  1. Open Analytics in the sidebar and click Create property.
  2. Enter a Name, such as Acme Store.
  3. Enter your site's Domain, such as example.com.
  4. Keep Web selected under Platform.
  5. Click Create property.

The Console opens the install screen and waits for your site's first event.

Add tracking to your site

Install the Web SDK in your site's project.

Bash
npm install appwrite

Add this code so it runs once in the browser when your site loads, for example in the entry file of your app or in a component at its root. The install screen shows the same setup with your endpoint, project ID, and property ID filled in.

JavaScript
import { Client, Analytics, Tracking } from 'appwrite';
const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>');
const tracking = new Tracking(new Analytics(client), '<PROPERTY_ID>');
tracking.start();

start() records pageviews, outbound link clicks, scroll depth, and engagement time.

See your first visit

Install tracking screen confirming that a pageview event was received
Install tracking screen confirming that a pageview event was received

Open your site in a browser. Within a few seconds, the install screen shows Event received with the first pageview.

Click Open dashboard to see the visit, with its page, source, location, browser, and device.

Next steps

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.