Data insert API
Add to cart
GET
https://data.thoughtmetric.io/d
Records an add-to-cart. These count toward the
add_to_carts metric on the REST API and are
attributed to a channel like any other conversion event.
Example request
curl -G https://data.thoughtmetric.io/d \
-d id=ID-bcd0aa692ce7e6b2 \
-d uid=8824a9fc-002d-4fb8-bcea-9e60225a88f0 \
-d ht=event \
-d ev=addToCart \
-d v=api \
-d ip=203.0.113.42 \
--data-urlencode dl=https://example-store.com/products/wool-crew \
-d ts=2024-01-31T18:22:04Z
<?php
$baseUrl = "https://data.thoughtmetric.io/d";
$params = [
"id" => "ID-bcd0aa692ce7e6b2",
"uid" => "8824a9fc-002d-4fb8-bcea-9e60225a88f0", // visitor uuid from your cookie
"ht" => "event",
"ev" => "addToCart",
"v" => "api",
"ip" => "203.0.113.42",
"dl" => "https://example-store.com/products/wool-crew",
"ts" => time(),
];
$url = $baseUrl . "?" . http_build_query($params);
file_get_contents($url);
const params = new URLSearchParams({
id: "ID-bcd0aa692ce7e6b2",
uid: "8824a9fc-002d-4fb8-bcea-9e60225a88f0",
ht: "event",
ev: "addToCart",
v: "api",
ip: "203.0.113.42",
dl: "https://example-store.com/products/wool-crew",
ts: new Date().toISOString(),
});
await fetch(`https://data.thoughtmetric.io/d?${params}`);
Query parameters
| id string, required | Your Project ID. |
| uid string, required | UUID identifying the visitor. |
| ht string, required | Always event for this call. |
| ev string, required | Always addToCart for this call. |
| v string | Always api for this call. |
| ip string | Visitor's IP address. |
| dl string | URL the add-to-cart happened on. |
| rl string | Referring URL. |
| ts string | Time of the event. ISO 8601 or Unix seconds. |
Notes
- No
edpayload is needed. Product details on add-to-cart are not currently recorded, only the event itself.