콘텐츠로 이동

이커머스 API

Markdown으로 보기

이커머스 API로 구매, 장바구니, 제품 이벤트를 보내고 매출 지표, 어트리뷰션, 코호트 데이터를 조회해요. 이벤트 수집은 publishable 키 또는 secret 키를 받아요. 쿼리 엔드포인트에는 secret 키가 필요해요.

모든 GET 이커머스 쿼리 엔드포인트는 분석 API와 같은 날짜 범위 파라미터를 받아요.

파라미터설명
days거슬러 조회할 일수. 기본값은 30. 플랜의 보관 기간 한도로 제한.
startISO 날짜(예: 2026-01-01). end와 함께 사용.
endISO 날짜(예: 2026-01-31). start와 함께 사용.

이커머스 이벤트 하나를 보내요.

POST/v1/api/analytics/ecommerce/track

인증: 유효한 API 키(publishable 또는 secret)

요청 본문:

{
"event_type": "purchase",
"transaction_id": "order_456",
"revenue": 49.99,
"currency": "USD",
"user_id": "user_123",
"coupon_code": "SAVE10",
"discount": 5.00,
"shipping": 4.99,
"tax": 3.75,
"items": [
{
"item_id": "sku_1",
"item_name": "T-Shirt",
"item_category": "Apparel",
"item_brand": "MyBrand",
"item_variant": "Red / L",
"price": 24.99,
"quantity": 2,
"currency": "USD"
}
],
"properties": {
"campaign": "spring-sale",
"source": "email"
}
}
이벤트 유형필수 필드설명
view_itemitems제품 페이지 조회
add_to_cartitems장바구니에 상품 추가
remove_from_cartitems장바구니에서 상품 제거
add_to_wishlistitems위시리스트에 상품 추가
view_cart(없음)장바구니 조회
add_payment_info(없음)결제 수단 입력
begin_checkout(없음)결제 과정 시작
purchasetransaction_id, revenue주문 완료
refundtransaction_id, revenue주문 환불
search(없음)제품 검색 (properties에 search_term 전달)
share(없음)제품 공유 (properties에 item_id 전달)
rate(없음)제품 평가 (properties에 item_id, rating 전달)
spend_creditsrevenue적립 포인트 사용
필드타입필수설명
event_typestring예위 13개 이벤트 유형 중 하나
transaction_idstring구매/환불 시고유 주문 식별자. 중복 제거에 사용
revenuenumber구매/환불/spend_credits 시총 매출 금액
currencystring아니요ISO 4217 통화 코드(예: USD, EUR). 기본값은 Appspace의 기준 통화
user_idstring아니요앱의 사용자 ID. 어트리뷰션에 필요
cart_idstring아니요장바구니 세션 ID. SDK가 자동으로 관리
coupon_codestring아니요적용된 쿠폰 또는 프로모션 코드
discountnumber아니요할인 금액
shippingnumber아니요배송비
taxnumber아니요세금 금액
itemsarray상품 이벤트 시상품 객체 배열 (아래 참고)
propertiesobject아니요추가 키-값 쌍(문자열 값)
필드타입필수설명
item_idstring예제품 SKU 또는 식별자
item_namestring아니요제품명
item_categorystring아니요제품 카테고리
item_brandstring아니요브랜드명
item_variantstring아니요옵션 (예: “Red / L”)
item_list_namestring아니요목록 또는 컬렉션 이름 (예: “Search Results”)
item_list_idstring아니요목록 식별자
item_image_urlstring아니요제품 이미지 URL
pricenumber아니요단가
quantitynumber아니요수량 (기본값 1)
currencystring아니요상품 단위 통화
coupon_codestring아니요상품 단위 쿠폰
discountnumber아니요상품 단위 할인

응답 200:

{ "ok": true }

오류:

상태오류
400event_type is required
400Invalid ecommerce event_type
400transaction_id is required for purchase events
400revenue is required for purchase events
403Ecommerce events are not available on the free tier
429Ecommerce event quota exceeded

이벤트는 부정 행위 규칙(봇 탐지, 불가능한 매출, 속도 제한, 통화 제한)에 따라 자동으로 검사돼요. 플래그가 지정된 이벤트(심각도 1)는 저장되지만 표시돼요. 차단된 이벤트(심각도 2)는 탐지 신호가 노출되지 않도록 { "ok": true }와 함께 조용히 거부돼요.

구매 및 환불 이벤트는 transaction_id로 중복이 제거돼요. 같은 거래 ID가 24시간 이내에 두 번 전송되면, 두 번째 이벤트는 조용히 무시돼요. 이렇게 하면 네트워크 재시도로 인해 매출이 중복 집계되지 않아요.


한 번의 요청으로 이커머스 이벤트를 최대 100개까지 보낼 수 있어요. 이 엔드포인트는 SDK가 주로 사용하는 엔드포인트예요.

POST/v1/api/analytics/ecommerce/batch

인증: 유효한 API 키(publishable 또는 secret)

요청 본문:

{
"events": [
{
"event_type": "add_to_cart",
"items": [{ "item_id": "sku_1", "item_name": "T-Shirt", "price": 24.99 }],
"user_id": "user_123"
},
{
"event_type": "purchase",
"transaction_id": "order_456",
"revenue": 49.99,
"currency": "USD",
"user_id": "user_123",
"items": [{ "item_id": "sku_1", "price": 24.99, "quantity": 2 }]
}
]
}

응답 200:

{
"ok": true,
"accepted": 2
}

일부 이벤트가 잘못된 경우, 해당 이벤트는 건너뛰어요:

{
"ok": true,
"accepted": 1,
"errors": [
"events[0]: transaction_id is required for purchase events"
]
}

오류:

상태오류
400events array is required and must not be empty
400Maximum 100 events per batch
403Ecommerce events are not available on the free tier

조회 기간의 총 매출 지표를 가져와요.

GET/v1/api/analytics/ecommerce/overview

인증: secret 키 필요

응답 200:

{
"total_revenue": 12450.00,
"net_revenue": 11200.00,
"total_orders": 245,
"total_refunds": 12,
"refund_amount": 1250.00,
"avg_order_value": 50.82,
"total_items_sold": 512,
"cart_abandonment_rate": 68.5,
"add_to_cart_rate": 32.1,
"days": 30
}

날짜별로 묶은 일별 매출을 가져와요.

GET/v1/api/analytics/ecommerce/revenue-timeseries

인증: secret 키 필요

응답 200:

{
"series": [
{ "date": "2026-01-01", "revenue": 450.00, "orders": 8 },
{ "date": "2026-01-02", "revenue": 620.00, "orders": 12 }
],
"days": 30
}

제품 조회부터 구매까지의 단계별 전환 퍼널을 가져와요.

GET/v1/api/analytics/ecommerce/funnel

인증: secret 키 필요

응답 200:

{
"steps": [
{ "name": "view_item", "count": 5000, "percentage": 100 },
{ "name": "add_to_cart", "count": 1600, "percentage": 32.0 },
{ "name": "view_cart", "count": 1200, "percentage": 75.0 },
{ "name": "begin_checkout", "count": 800, "percentage": 66.7 },
{ "name": "add_payment_info", "count": 600, "percentage": 75.0 },
{ "name": "purchase", "count": 400, "percentage": 66.7 }
],
"days": 30
}

각 percentage는 이전 단계 대비 비율이에요(view_item은 항상 100이에요).


매출 기준 베스트셀러 제품을 가져와요.

GET/v1/api/analytics/ecommerce/top-products

인증: secret 키 필요

쿼리 파라미터:

파라미터기본값최댓값설명
limit20100반환할 제품 수

응답 200:

{
"products": [
{ "item_id": "sku_1", "item_name": "T-Shirt", "revenue": 2499.00, "quantity": 100, "orders": 85 },
{ "item_id": "sku_2", "item_name": "Hoodie", "revenue": 1899.00, "quantity": 38, "orders": 35 }
],
"days": 30
}

캠페인, 소스, 매체별 매출 내역을 가져와요.

GET/v1/api/analytics/ecommerce/revenue-by-channel

인증: secret 키 필요

응답 200:

{
"channels": [
{
"campaign": "spring-sale",
"source": "email",
"medium": "newsletter",
"revenue": 4500.00,
"orders": 90,
"conversion_rate": 3.2
}
],
"days": 30
}

쿠폰 코드별 매출과 사용 통계를 가져와요.

GET/v1/api/analytics/ecommerce/revenue-by-coupon

인증: secret 키 필요

응답 200:

{
"coupons": [
{ "coupon_code": "SAVE10", "revenue": 1200.00, "orders": 40, "avg_discount": 12.50 }
],
"days": 30
}

기기 유형별 매출 내역을 가져와요.

GET/v1/api/analytics/ecommerce/revenue-by-device

인증: secret 키 필요

응답 200:

{
"devices": [
{ "device_type": "mobile", "revenue": 8200.00, "orders": 165 },
{ "device_type": "desktop", "revenue": 4250.00, "orders": 80 }
],
"days": 30
}

운영체제 플랫폼별 매출 내역을 가져와요.

GET/v1/api/analytics/ecommerce/revenue-by-platform

인증: secret 키 필요

응답 200:

{
"platforms": [
{ "platform": "ios", "revenue": 6500.00, "orders": 130 },
{ "platform": "android", "revenue": 3900.00, "orders": 78 },
{ "platform": "web", "revenue": 2050.00, "orders": 37 }
],
"days": 30
}

국가별 매출 내역을 가져와요.

GET/v1/api/analytics/ecommerce/revenue-by-country

인증: secret 키 필요

응답 200:

{
"countries": [
{ "country": "US", "revenue": 9200.00, "orders": 185 },
{ "country": "GB", "revenue": 2100.00, "orders": 42 }
],
"days": 30
}

장바구니 이탈 지표를 가져와요.

GET/v1/api/analytics/ecommerce/cart-abandonment

인증: secret 키 필요

응답 200:

{
"abandonment_rate": 68.5,
"abandoned_carts": 520,
"abandoned_revenue": 32000.00,
"completed_carts": 238,
"days": 30
}

설정 가능한 어트리뷰션 모델과 기간으로, 캠페인 또는 링크별 매출 어트리뷰션을 가져와요.

GET/v1/api/analytics/ecommerce/attribution

인증: secret 키 필요

쿼리 파라미터:

파라미터기본값옵션설명
group_bycampaigncampaign, linkUTM 캠페인 또는 구매자가 앱을 연 링크(라우트)에 매출 기여
modellast_clicklast_click, linear, time_decay어트리뷰션 모델
window307, 14, 30, 60, 90어트리뷰션 기간(일)

그 밖의 group_by 값은 400을 반환해요. 매출 금액은 환불 전, 기준 통화의 센트 단위예요.

응답 200, group_by=campaign:

{
"ok": true,
"data": {
"attributed": [
{
"campaign": "spring-sale",
"source": "email",
"medium": "newsletter",
"attributed_revenue": 450000,
"attributed_orders": 90
}
],
"unattributed_revenue": 210000,
"unattributed_orders": 45
},
"model": "last_click",
"window": 30,
"group_by": "campaign"
}

응답 200, group_by=link:

{
"ok": true,
"data": {
"links": [
{
"route_id": "6650f1c2a9d4",
"prefix": "product",
"name": "Product pages",
"deleted": false,
"clicks": 6120,
"installs": 214,
"opens": 3790,
"attributed_orders": 612,
"attributed_revenue": 1942000,
"buyers": 548,
"revenue_per_click": 317,
"matched_share": 0.12
}
],
"attributed_revenue": 3322000,
"attributed_orders": 1041,
"unattributed_revenue": 1340000,
"unattributed_orders": 371,
"total_revenue": 4662000,
"total_orders": 1412,
"no_user_orders": 212,
"no_user_share": 0.15
},
"model": "last_click",
"window": 30,
"group_by": "link"
}

group_by=link일 때:

  • clicks는 앱 열기를 포함해 링크를 탭한 모든 횟수를 세므로, clicks와 opens를 더하지 마세요.
  • matched_share는 설치된 앱을 정확히 연 경우가 아니라, 첫 열기 이후 매칭된 설치를 통해 발생한 링크 매출의 비율이에요.
  • no_user_share는 사용자 ID 없이 전송된 구매 중, 어떤 링크와도 매칭할 수 없는 비율이에요.
  • 마지막 클릭: 매출 기여도의 100%가 구매 전 사용자가 마지막으로 클릭한 캠페인에 돌아가요.
  • 선형: 매출은 어트리뷰션 기간 내에 사용자가 클릭한 모든 캠페인에 균등하게 나뉘어요.
  • 시간 감쇠: 최근 클릭일수록 더 많은 기여도를 받고, 오래된 클릭일수록 지수적으로 감소해요.

획득 월별로 이후 월에 걸친 매출을 보여 주는 코호트 매트릭스를 가져와요.

GET/v1/api/analytics/ecommerce/cohorts

인증: secret 키 필요

쿼리 파라미터:

파라미터기본값설명
months6포함할 코호트 개월 수

응답 200:

{
"cohorts": [
{
"month": "2026-01",
"users": 120,
"revenue_by_month": {
"0": 3200.00,
"1": 1800.00,
"2": 900.00
}
},
{
"month": "2025-12",
"users": 95,
"revenue_by_month": {
"0": 2800.00,
"1": 1500.00,
"2": 750.00,
"3": 400.00
}
}
],
"avg_ltv": 82.50,
"total_purchasing_users": 580
}

revenue_by_month의 각 키는 사용자의 첫 구매 이후 경과한 개월 수예요. 0번째 개월은 획득 월이에요.


특정 사용자의 이커머스 이벤트 기록을 가져와요.

GET/v1/api/analytics/ecommerce/user-journey?user_id=user_123

인증: secret 키 필요

쿼리 파라미터:

파라미터필수설명
user_id예조회할 사용자 ID

응답 200:

{
"events": [
{
"event_type": "view_item",
"timestamp": "2026-01-15T10:30:00Z",
"items": [{ "item_id": "sku_1", "item_name": "T-Shirt" }]
},
{
"event_type": "add_to_cart",
"timestamp": "2026-01-15T10:31:00Z",
"items": [{ "item_id": "sku_1" }]
},
{
"event_type": "purchase",
"timestamp": "2026-01-15T10:35:00Z",
"transaction_id": "order_456",
"revenue": 49.99
}
],
"user_id": "user_123"
}

특정 사용자의 모든 분석 이벤트를 삭제해요. 이 작업은 모든 ClickHouse 테이블(events, event_items, event_properties)에서 해당 사용자의 데이터를 제거해요.

DELETE/v1/api/analytics/user/:userId

인증: secret 키 필요

URL 파라미터: :userId는 삭제할 사용자 ID예요.

응답 200:

{ "ok": true, "deleted_user_id": "user_123" }

삭제는 비동기로 처리돼요. 보통 몇 분 안에 데이터가 제거돼요.


모든 매출 값은 실시간 환율을 사용해 Appspace의 기준 통화로 자동 변환돼요(Open Exchange Rates에서 매시간 업데이트되며, 200개 이상의 통화를 지원해요).

구매 이벤트에 currency 필드가 없으면 Appspace의 기준 통화가 기본값으로 사용돼요. 기준 통화는 Appspace 설정 > 이커머스에서 설정해요.

소수점이 없는 통화(JPY, KRW, VND 등)는 자동으로 처리돼요. 정밀도를 위해 매출은 내부적으로 센트 단위로 저장돼요.

이 페이지가 도움이 됐나요?