Counts custom events
GET
https://api.vercel.com/v1/query/web-analytics/events/countCounts the number of custom events on a project (production only), since Web Analytics was enabled. Results can be filtered on supported dimensions.
Request
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({ bearerToken: "<YOUR_BEARER_TOKEN_HERE>",});
async function run() { const result = await vercel.webAnalytics.countEvents({ projectId: "prj_XLKmu1DyR1eY7zq8UgeRKbA7yVLA", since: "2024-09-01T00:00:00.000Z", until: "2024-09-08T00:00:00.000Z", filter: "eventName eq 'signup'", teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l", slug: "my-team-url-slug", });
console.log(result);}
run();Response
{ "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"}AuthorizationbearerToken
Default authentication mechanism
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.
Timestamp in milliseconds, or a valid Date string.
Selects data until (including) this date.
Will be adjusted according to the desired time granularity.
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/ , eventData/ , 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.