Leverage Rebuy AI's event stream technology to surface smart product and shopping experience recommendations.
Event Format
A user (subject) views (action) a t-shirt (noun).
Rebuy will store the event so it can be included in analytics at a later time.
Generating a client-side UUID
At this time, the client is responsible for generating a UUID to be included with the request.
We recommend using this NPM package (UUID) to generate the UUID.
We also recommend storing this session-based UUID if you plan on using the /products/viewed endpoint.
Generate a UUID for the customer if one hasn't been created already.
Build your POST data with the appropriate subject, verb, and noun (ex. user, viewed, product) and corresponding product data (ex. shopify_product_handle)
Submit your request when a customer views a product.
Once you've submitted data to this endpoint, you can call the /products/viewed endpoint using the customer's established UUID to get a list of products that they've viewed throughout their session.
The 'Universally Unique Identifier' of the subject - the client is responsible for creating the token that represents the session. We recommend using this NPM package (https://www.npmjs.com/package/uuid). Example value: be6f5fab-32a4-43e5-967c-68017baa3aa5
// POST https://rebuyengine.com/api/v1/analytics/eventconstparams=newURLSearchParams({key:"YOUR_VALUE",subject:"YOUR_VALUE"});fetch(`https://rebuyengine.com/api/v1/analytics/event?${params}`).then(response=>response.json()).then(data=>console.log(data));
{"error":"Missing required args. You must pass either shopify_customer_id or uuid."}
---
title: Event
status: deprecated
excerpt: Logs analytics data from customers who view products.
api:
file: rebuy-analytics.json
operationId: analytics-event
deprecated: true
hidden: false
metadata:
title: ''
description: ''
robots: index
next:
description: ''
pages:
- type: endpoint
slug: viewed
title: Viewed
---
!!! warning "Deprecated"
This page documents a deprecated feature. It may be removed in a future version.
## POST /api/v1/analytics/event
## Rebuy Event Streams
Leverage Rebuy AI's event stream technology to surface smart product and shopping experience recommendations.
!!! note "Event Format"
A user (subject) views (action) a t-shirt (noun).
Rebuy will store the event so it can be included in analytics at a later time.
!!! warning "Generating a client-side UUID"
At this time, the client is responsible for generating a UUID to be included with the request.
We recommend using [this NPM package (UUID)](https://www.npmjs.com/package/uuid) to generate the UUID.
We also recommend storing this session-based UUID if you plan on using the [/products/viewed](viewed.md) endpoint.
## How to Use the /event Endpoint
1. Generate a UUID for the customer if one hasn't been created already.
2. Build your POST data with the appropriate subject, verb, and noun (ex. user, viewed, product) and corresponding product data (ex. shopify_product_handle)
3. Submit your request when a customer views a product.
Once you've submitted data to this endpoint, you can call the [/products/viewed](viewed.md) endpoint using the customer's established UUID to get a list of products that they've viewed throughout their session.
## Query Parameters
`key` · string
: The key to use our API.
`subject` · string
: The subject of the event. Supported value: [user].
`verb` · string
: The action of the subject of the event. Supported values: [viewed, added, removed].
`noun` · string
: The object that the subject's action operated upon. Supported value: [product].
`shopify_product_handle` · string
: Shopify's primary identifier for a product - required when the noun is product-based. Example: classic-beanie
`subject_email` · string
: The email of the subject. Example: [email protected]
`theme_id` · string
: The theme identifier that applies to the product.
`uuid` · string
: The 'Universally Unique Identifier' of the subject - the client is responsible for creating the token that represents the session. We recommend using this NPM package (https://www.npmjs.com/package/uuid). Example value: be6f5fab-32a4-43e5-967c-68017baa3aa5
## Code Example
```javascript
// POST https://rebuyengine.com/api/v1/analytics/event
const params = new URLSearchParams({
key: "YOUR_VALUE",
subject: "YOUR_VALUE"
});
fetch(`https://rebuyengine.com/api/v1/analytics/event?${params}`)
.then(response => response.json())
.then(data => console.log(data));
```
## Response Examples
### 200 OK
```json
{
"data": "Received"
}
```
### 400 Bad Request
```json
{
"error": "Missing required args. You must pass either shopify_customer_id or uuid."
}
```