Remove from Cart Event
Track when users remove items from their shopping cart. This helps analyze cart abandonment patterns, product interest fluctuations, and cart modification behavior for funnel optimization.
When to Use This Event
Trigger this event when a user removes one or more items from their cart:
- User clicks "Remove" on a cart item
- User decreases quantity to zero
- User clears entire cart (fire one event per removed item or one consolidated event)
Send this event from your backend with /v1/cart/remove, or from the
browser with Axitrace._instance.track('remove_from_cart', { ... }). Both paths write the
same row and forward to the same destinations.
If your shop already has a GA4 ecommerce dataLayer, you do not need to call anything at
all: turn on autoTrackDataLayer and the SDK translates your existing
GA4 remove_from_cart push into this event. See the
Google Tag Manager guide.
The browser path is deliberately more forgiving than /v1/cart/remove: a
missing currency or an empty items array is accepted rather than rejected, because a
dataLayer is often not under your control field by field. The REST endpoint keeps the
strict contract for backend callers, who are.
This event does not map to any Facebook or TikTok standard event, so no pixel fires and no Meta or TikTok CAPI event is sent - there is no standard event on either platform to optimise toward, and inventing a custom one would create a conversion you never asked for. It can be forwarded to Google Analytics 4, where it is a recommended event: tick it on your GA4 connection under Events to forward. It is stored in AxiTrace for internal analytics (cart modification tracking, abandonment funnel analysis) whether or not you forward it anywhere.
If your shop already sends this event to GA4 with its own gtag.js or GTM tag, leave the checkbox off. Forwarding it as well would have GA4 count the same action twice. Forward it when AxiTrace is your only source for it.
Request Parameters
User Identification
At least one of these identifiers is required:
| Field | Type | Description |
|---|---|---|
client_id |
string | Your custom user/visitor identifier (use SDK's vt_vid cookie value) |
user_id |
string | Authenticated user ID |
session_id |
string | Current session identifier (use SDK's vt_sid cookie value) |
Required Fields
| Field | Type | Required | Description |
|---|---|---|---|
currency |
string | Required | Currency code (ISO 4217, e.g., USD, EUR). Must be non-empty. |
value |
number | Required | Total value of removed items. Must be >= 0. |
items |
array | Required | Array of removed item objects. Must contain at least one item. |
Item Object
| Field | Type | Description |
|---|---|---|
item_id |
string | Product SKU or ID |
item_name |
string | Product name |
price |
number | Unit price |
quantity |
integer | Quantity removed |
item_category |
string | Product category |
item_brand |
string | Product brand |
Optional Fields
| Field | Type | Description |
|---|---|---|
params |
object | Additional parameters (custom metadata, analytics tags) |
Examples
JavaScript SDK (browser)
// Browser, with the JavaScript SDK. The SDK supplies the visitor and session
// ids from its own cookies, so no client_id or session_id is needed.
Axitrace._instance.track('remove_from_cart', {
currency: 'PLN',
value: 698.00,
items: [
{ item_id: 'SKU-1', item_name: 'Trail Runner', price: 349.00, quantity: 2 }
]
});
Server-Side (AxiTrace PHP SDK)
<?php
use AxiTrace\AxiTrace;
// Initialize - auto-reads vt_vid, vt_sid cookies
$axitrace = AxiTrace::init('sk_live_YOUR_SECRET_KEY');
// Track item removal
$response = $axitrace->removeFromCart(29.99, 'USD', [
[
'item_id' => 'SKU-12345',
'item_name' => 'Blue Running Shoes',
'price' => 29.99,
'quantity' => 1,
'item_category' => 'Footwear',
'item_brand' => 'Nike',
]
]);
Server-Side (cURL)
curl -X POST https://stat.axitrace.com/v1/cart/remove \
-u "sk_live_YOUR_SECRET_KEY:" \
-H "Content-Type: application/json" \
-d '{
"client_id": "value-from-vt_vid-cookie",
"session_id": "value-from-vt_sid-cookie",
"currency": "USD",
"value": 29.99,
"items": [
{
"item_id": "SKU-12345",
"item_name": "Blue Running Shoes",
"price": 29.99,
"quantity": 1,
"item_category": "Footwear",
"item_brand": "Nike"
}
]
}'
Server-Side (Python)
import os
import requests
from flask import request
secret_key = os.environ.get('AXITRACE_SECRET_KEY')
# Read AxiTrace SDK cookies
visitor_id = request.cookies.get('vt_vid')
session_id = request.cookies.get('vt_sid')
# Track item removal
requests.post(
'https://stat.axitrace.com/v1/cart/remove',
auth=(secret_key, ''),
json={
'client_id': visitor_id,
'session_id': session_id,
'currency': 'USD',
'value': 29.99,
'items': [{
'item_id': 'SKU-12345',
'item_name': 'Blue Running Shoes',
'price': 29.99,
'quantity': 1,
'item_category': 'Footwear',
'item_brand': 'Nike',
}]
}
)
Response
Success Response (200 OK)
{
"success": true,
"eventId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"action": "remove_from_cart"
}
Error Responses
| Status | Error | Description |
|---|---|---|
400 |
at least one of client_id, user_id, or session_id is required |
No user identifier provided |
400 |
currency, value >= 0, and items are required |
Missing currency, negative value, or empty items array |
401 |
unauthorized |
Invalid or missing API key |
Best Practices
- Track the specific items removed - Include full item details (item_id, item_name, price, quantity) for granular analytics
- Set value to the removed total - Use
value = unit_price × quantityfor the items being removed - Link to browser session - Pass SDK cookie values (
vt_vid,vt_sid) to connect cart removals with user profiles - Use consistent item_id - Match the
item_idused inproduct.addToCartandtransaction.chargefor funnel analysis