---
title: counts-custom-events
product: vercel
url: /docs/rest-api/web-analytics/counts-custom-events
canonical_url: "https://vercel.com/docs/rest-api/web-analytics/counts-custom-events"
last_updated: 2026-10-06
type: reference
prerequisites:
  []
related:
  - /docs/rest-api
summary: Learn about counts-custom-events on Vercel.
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---

# Counts custom events

```http
GET /v1/query/web-analytics/events/count
```

Counts the number of custom events on a project (production only), since Web Analytics was enabled. Results can be filtered on supported dimensions.

## Authentication

**bearerToken**: HTTP bearer

## Query parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `projectId` | string | Yes | The project identifier or the project name |
| `since` | object | No | Timestamp in milliseconds, or a valid Date string.  Selects data from (including) this date and time. Will be adjusted according to the desired time granularity. |
| `until` | object | No | Timestamp in milliseconds, or a valid Date string.  Selects data until (including) this date. Will be adjusted according to the desired time granularity. |
| `filter` | string. maxLength: 2048 | No | OData-compliant filter. Encode the value when sending it in a URL.  Allows filtering on one or multiple dimensions.  Supported dimensions: country, deviceType, environment, requestPath, referrerHostname, osName, browserName, route, utmSource, utmMedium, utmCampaign, utmContent, utmTerm, eventName.  JSON dimensions filtered by key: flags/<name>, eventData/<property>, for example eventData/plan eq 'pro'. Wrap keys containing characters other than letters, digits, and underscores in single quotes, for example flags/'my-flag' eq 'true'.  Supported operations include eq, ne, in, and logical operators and, or, not with parentheses. Functions such as startswith are supported by the OData parser. |
| `teamId` | string | No | The Team identifier to perform the request on behalf of. |
| `slug` | string | No | The Team slug to perform the request on behalf of. |


## Example request

### TypeScript

```typescript
const response = await fetch('https://api.vercel.com/v1/query/web-analytics/events/count?projectId=string&since=value&until=value&filter=string&teamId=string&slug=string', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
    'Content-Type': 'application/json',
  },
});

const data = await response.json();
console.log(data);
```

### Next.js

```typescript
'use server';

export async function callEndpoint() {
  const response = await fetch('https://api.vercel.com/v1/query/web-analytics/events/count?projectId=string&since=value&until=value&filter=string&teamId=string&slug=string', {
    method: 'GET',
    headers: {
      'Authorization': `Bearer ${process.env.VERCEL_ACCESS_TOKEN}`,
      'Content-Type': 'application/json',
    },
    next: { revalidate: 3600 }
  });

  if (!response.ok) {
    throw new Error('Request failed');
  }

  return response.json();
}
```

### cURL

```bash
curl -X GET 'https://api.vercel.com/v1/query/web-analytics/events/count?projectId=string&since=value&until=value&filter=string&teamId=string&slug=string' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json'
```

## Example response

```json
{
  "data": {
    "browserName": "Example Name",
    "country": "string",
    "deviceType": "string",
    "environment": "string",
    "eventData": "string",
    "eventName": "Example Name",
    "flags": "string",
    "osName": "Example Name",
    "projectId": "example_id",
    "projectName": "Example Name",
    "referrerHostname": "Example Name",
    "requestHostname": "Example Name",
    "requestPath": "string",
    "route": "string",
    "utmCampaign": "string",
    "utmContent": "string",
    "utmMedium": "string",
    "utmSource": "string",
    "utmTerm": "string",
    "visitorId": "example_id"
  },
  "query": {
    "filter": "string",
    "since": "string",
    "until": "string"
  },
  "version": "123"
}
```

## Responses

### 200: No description

Content-Type: `application/json`

```json
{
  "type": "object",
  "required": [
    "data",
    "query",
    "version"
  ],
  "properties": {
    "data": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "browserName",
            "country",
            "deviceType",
            "environment",
            "eventData",
            "eventName",
            "flags",
            "osName",
            "projectId",
            "projectName",
            "referrerHostname",
            "requestHostname",
            "requestPath",
            "route",
            "utmCampaign",
            "utmContent",
            "utmMedium",
            "utmSource",
            "utmTerm",
            "visitorId"
          ],
          "properties": {
            "browserName": {
              "type": "string"
            },
            "country": {
              "type": "string"
            },
            "deviceType": {
              "type": "string"
            },
            "environment": {
              "type": "string"
            },
            "eventData": {
              "type": "string"
            },
            "eventName": {
              "type": "string"
            },
            "flags": {
              "type": "string"
            },
            "osName": {
              "type": "string"
            },
            "projectId": {
              "type": "string"
            },
            "projectName": {
              "type": "string"
            },
            "referrerHostname": {
              "type": "string"
            },
            "requestHostname": {
              "type": "string"
            },
            "requestPath": {
              "type": "string"
            },
            "route": {
              "type": "string"
            },
            "utmCampaign": {
              "type": "string"
            },
            "utmContent": {
              "type": "string"
            },
            "utmMedium": {
              "type": "string"
            },
            "utmSource": {
              "type": "string"
            },
            "utmTerm": {
              "type": "string"
            },
            "visitorId": {
              "type": "string"
            }
          },
          "additionalProperties": {
            "type": "number",
            "nullable": true
          }
        },
        {
          "type": "object",
          "required": [
            "count",
            "visitors"
          ],
          "properties": {
            "count": {
              "type": "number"
            },
            "visitors": {
              "type": "number"
            }
          }
        }
      ]
    },
    "query": {
      "type": "object",
      "required": [
        "since",
        "until"
      ],
      "properties": {
        "filter": {
          "type": "string"
        },
        "since": {
          "type": "string"
        },
        "until": {
          "type": "string"
        }
      }
    },
    "version": {
      "type": "number"
    }
  }
}
```

### 400: One of the provided values in the request query is invalid.

### 401: The request is not authorized.

### 402: No description

### 403: You do not have permission to access this resource.

### 404: No description

### 410: No description

### 503: No description

---

## Related

- [web-analytics endpoints](/docs/rest-api#web-analytics)

- [REST API overview](/docs/rest-api)

- [OpenAPI spec](https://vercel.com/openapi.json) (machine-readable, all endpoints)

---

[View full sitemap](/docs/sitemap)
