Export events
Export events from an application.
Example
Here is an example of how to export events:
const url = new URL('https://api.croct.io/export/events');url.searchParams.append('start', '1440990000000');url.searchParams.append('end', '1441076400000');url.searchParams.append('pageSize', '100');url.searchParams.append('events', 'productViewed');url.searchParams.append('events', 'checkoutStarted');url.searchParams.append('events', 'orderPlaced');
const response = await fetch(url, { headers: { 'X-Api-Key': '<API KEY>', },});
const {metadata, items, nextCursor} = await response.json();Headers
This endpoint requires the following HTTP headers:
Parameters
This endpoint accepts the following query parameters:
- start(optional)integer
The earliest event time to include, in milliseconds since epoch.
Only events that occurred at or after this time are included.
- end(optional)integer
The latest event time to include, in milliseconds since epoch.
Only events that occurred before this time are included. If not provided, there is no upper time limit.
- pageSize(optional)integer
The maximum number of events returned per request.
Must be between 1 and 1000.
Default:100- cursor(optional)string
A cursor for retrieving the next page of results.
If omitted, export starts from the beginning of the specified time window.
- events(optional)Array<string>
The list of event types to include. By default, all event types are included.
Here are the supported event types:
Event Constant userSignedUp EventType.USER_SIGNED_UP userSignedIn EventType.USER_SIGNED_IN userSignedOut EventType.USER_SIGNED_OUT tabOpened EventType.TAB_OPENED tabUrlChanged EventType.TAB_URL_CHANGED tabVisibilityChanged EventType.TAB_VISIBILITY_CHANGED locationDetected EventType.LOCATION_DETECTED clientDetected EventType.CLIENT_DETECTED pageOpened EventType.PAGE_OPENED pageLoaded EventType.PAGE_LOADED productAbandoned EventType.PRODUCT_ABANDONED productViewed EventType.PRODUCT_VIEWED cartAbandoned EventType.CART_ABANDONED cartViewed EventType.CART_VIEWED cartModified EventType.CART_MODIFIED checkoutStarted EventType.CHECKOUT_STARTED orderPlaced EventType.ORDER_PLACED nothingChanged EventType.NOTHING_CHANGED goalCompleted EventType.GOAL_COMPLETED eventOccurred EventType.EVENT_OCCURRED slotPersonalized EventType.SLOT_PERSONALIZED leadGenerated EventType.LEAD_GENERATED audienceMatched EventType.AUDIENCE_MATCHED userClicked EventType.USER_CLICKED userScrolled EventType.USER_SCROLLED
Response
This endpoint returns a JSON response with the following properties:
- dataobject
The response containing exported events and pagination information.
- itemsArray<object>
The list of exported events.
See the Event types reference for the complete event structure.
- nextCursorstring
An opaque cursor for retrieving the next page of results.
The value is an empty string when there are no more results. Treat it as opaque and pass it back unchanged on the next request.
- metadataobject
Metadata about the workspace and application.
- organizationNamestring
The name of the organization.
- organizationSlugstring
The URL-friendly identifier of the organization.
- workspaceNamestring
The name of the workspace.
- workspaceSlugstring
The URL-friendly identifier of the workspace.
- applicationNamestring
The name of the application.
- applicationSlugstring
The URL-friendly identifier of the application.
- organizationName
- items
Example response
Here is an example of a JSON response from this endpoint:
{ "metadata": { "organizationName": "Acme Corp", "organizationSlug": "acme-corp", "workspaceName": "Production", "workspaceSlug": "production-app", "applicationName": "E-commerce Store", "applicationSlug": "ecommerce-store" }, "items": [ { "id": "924f6c8f-3b5b-47ea-b483-25a0506dc436", "sessionId": "343dd18a-1ab1-4298-8b19-f14880ba4e9c", "userId": "91d286ab-654a-47a3-ae3f-a0c0d661e44d", "timestamp": 1440990000000, "context": { "type": "web", "tabId": "0b032685-0a7e-4cdd-9ff1-9d3af33507a4", "url": "https://www.example.com" }, "payload": { "@type": "userSignedIn", "externalUserId": "user-123" } } ], "nextCursor": "eyJzZXNzaW9uSWQiOiIxMjM0NSIsInRpbWVzdGFtcCI6MTYwOTQ1OTMwMDAwMH0"}