# API Product Analytics

This guide provides an extended explanation of how to use the API Product Analytics endpoint.

API Product Analytics is a new API data endpoint that accepts up to six parameters and allows us to help you generate more revenue. Please upload the relevant information using this endpoint:

`v2/products/{product_uuid}/visits`

Here is a list of the fields supported. Note that only the first three are required.

- `productUrl` (string): The URL of the product on your website. **(Required)**
- `environment` (string): The product URL environment (e.g., `live`, `staging`, `test`, `development`). **(Required)**
- `platform` (string): The product URL platform (e.g., `web`, `mobile`, `offline`, `others`). **(Required)**
- `userIp` (string): The IP address of the user visiting the page.
- `userAgent` (string): The web browser user agent of the user visiting the page.
- `userLanguage` (string): The language displayed on the product page (using the 2-character language code from ISO 639-1).


You should implement this API endpoint at the following events:

- **During the publication of the product (on mobile or web):**
When publishing the product on your platform, make a request to the API and pass the three required parameters: `productUrl`, `environment`, and `platform`.
- **On the product detail page:**
If possible, in addition to the required parameters, pass in the four optional parameters.


### Example Request

- **Product UUID:** `d3bfa3e1-edd4-5c24-a051-4d6c56aae621`
- **API URL:** `v2/products/d3bfa3e1-edd4-5c24-a051-4d6c56aae621/visits`
- **HTTP method:** `POST`


#### Example Request Body


```json
{
  "productUrl": "http://mydomain.com/d3bfa3e1-edd4-5c24-a051-4d6c56aae621/view",
  "environment": "live",
  "platform": "web",
  "userIp": "192.168.1.1",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
  "userLanguage": "en"
}
```

#### Example Response


```json
{
  "code": 200,
  "message": "Submission successful.",
  "timestamp": "2019-02-15T12:24:26.009+08:00"
}
```