Track Sale
curl --request POST \
--url https://api.example.com/api/events/saleimport requests
url = "https://api.example.com/api/events/sale"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/events/sale', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/events/sale",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/events/sale"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/events/sale")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/events/sale")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyEvents API
Track Sale
Create a sale conversion event
POST
/
api
/
events
/
sale
Track Sale
curl --request POST \
--url https://api.example.com/api/events/saleimport requests
url = "https://api.example.com/api/events/sale"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/events/sale', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/events/sale",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/events/sale"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/events/sale")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/events/sale")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyEndpoint
POST https://track.taap.it/api/events/sale
Authentication
- Server-side (Recommended)
- Client-side
Use your secret API key:
Authorization: Bearer taapit_sk_xxxxxxxxxxxx
Use your publishable key:
X-Publishable-Key: taapit_pk_xxxxxxxxxxxx
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
trackingId | string | ✓ | The ta_tid from the cookie or URL parameter |
customer | object | ✓ | Customer information |
customer.externalId | string | ✓ | Your internal user/customer ID |
customer.email | string | Customer’s email address | |
customer.firstname | string | Customer’s first name | |
customer.lastname | string | Customer’s last name | |
customer.phoneNumber | string | Customer’s phone number | |
customer.avatarUrl | string | URL to customer’s avatar image | |
amount | number | ✓ | Transaction amount in currency units (not cents) |
currency | string | ✓ | ISO 4217 currency code (e.g., eur, usd) |
metadata | object | Additional custom data (key-value pairs) |
Amount format: Use currency units, not cents.
- ✅
29.99for €29.99 - ❌
2999would be interpreted as €2999
Examples
- cURL
- Node.js SDK
- React Hook
- JavaScript
curl -X POST https://track.taap.it/api/events/sale \
-H "Authorization: Bearer taapit_sk_xxx" \
-H "Content-Type: application/json" \
-d '{
"trackingId": "rLnWe1uz9t282v7g",
"customer": {
"externalId": "user_123",
"email": "john@example.com"
},
"amount": 99.99,
"currency": "eur",
"metadata": {
"orderId": "order_456",
"plan": "pro"
}
}'
import { Taapit } from 'taapit-sdk';
const taapit = new Taapit({
apiKey: process.env.TAAPIT_API_KEY,
});
await taapit.track.sale({
trackingId: 'rLnWe1uz9t282v7g',
customer: {
externalId: 'user_123',
email: 'john@example.com',
},
amount: 99.99,
currency: 'eur',
metadata: {
orderId: 'order_456',
plan: 'pro',
},
});
import { useTaapitAnalytics } from 'taapit-sdk/react';
function CheckoutButton({ order }) {
const { trackSale } = useTaapitAnalytics();
const handlePurchase = async () => {
trackSale({
customer: {
externalId: order.userId,
email: order.email,
},
amount: order.total,
currency: 'eur',
metadata: {
orderId: order.id,
plan: order.plan,
},
});
};
}
<script src="https://taap.it/api/sdk" data-publishable-key="taapit_pk_xxx"></script>
<script>
taapit.trackSale({
customer: {
externalId: 'user_123',
email: 'john@example.com',
},
amount: 99.99,
currency: 'eur',
metadata: {
orderId: 'order_456',
},
});
</script>
Response
- 200 OK
- 400 Bad Request
- 401 Unauthorized
- 404 Not Found
{
"ok": true
}
{
"error": "Invalid payload",
"details": [
{
"path": ["amount"],
"message": "Required"
}
]
}
{
"error": "Invalid API key"
}
{
"error": "Click not found for this trackingId"
}
Currency Codes
Use standard ISO 4217 currency codes:| Currency | Code |
|---|---|
| Euro | eur |
| US Dollar | usd |
| British Pound | gbp |
| Japanese Yen | jpy |
| Swiss Franc | chf |
| Canadian Dollar | cad |
| Australian Dollar | aud |
Error Codes
| HTTP Code | Error | Description |
|---|---|---|
| 400 | Invalid payload | Request body validation failed |
| 400 | Missing customer.externalId | Required field not provided |
| 401 | Invalid API key | API key is invalid or revoked |
| 401 | Hostname not in allowed list | Origin not whitelisted (client-side) |
| 403 | This click does not belong to your workspace | trackingId is for a different workspace |
| 404 | Click not found for this trackingId | trackingId doesn’t exist or has expired |
⌘I