VI
Nhắn Messenger
API Facebook
Dành cho developer

Tạo chuyển đổi tùy chỉnh (theo URL / sự kiện pixel) — API Facebook

Create Custom Conversion · gọi qua Quantri360 bằng một API key cho chính tài khoản / tài sản bạn đã kết nối và ủy quyền — 360 lo việc ký request và làm mới phiên đăng nhập bạn đã cấp.

Create Custom Conversion

POST/{version}/act_{account_id}/customconversionsGọi qua 360: POST https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/customconversions
Endpoint ghi — thay đổi dữ liệu trên Facebook. Key phải được tạo với tick "Cho phép gọi API ghi", nếu không sẽ nhận 403 write_not_allowed. Mỗi lần gọi được ghi nhật ký.
Mô tả API

Tạo chuyển đổi tùy chỉnh theo URL hoặc sự kiện pixel (vd trang cảm ơn sau khi mua) để tối ưu và đo quảng cáo. ENDPOINT GHI.

  • Là API GHI; key cần quyền ghi (can_write) và gói mở module Quảng cáo, mỗi lần gọi được 360 ghi nhật ký.
  • Mỗi tài khoản quảng cáo tối đa 100 chuyển đổi tùy chỉnh. Xóa chuyển đổi (DELETE /{id}) chưa mở qua 360.

Request

Địa chỉ

POST https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/customconversions

Xác thực & gian hàng

TênVị tríKiểuMẫuMô tả
AuthorizationheaderheaderBearer q360_live_ab12cd34_…Khóa API của brand (tạo ở mục API key). Bắt buộc với mọi request. Brand suy từ key — không truyền mã brand.
platform_shop_idquerystringact_123456789 hoặc 1234567890Tài sản Facebook brand đã nối với 360: tài khoản quảng cáo (act_<id> hoặc <id>), Page id hoặc Pixel id — lấy ở GET /v1/platforms. Có thể bỏ khi đường dẫn đã chứa act_<id> / page id của brand.

Tham số request

TênVị tríKiểuBắt buộcMẫuMô tả
versionpathstringCóv25.0
account_idpathstringCó1000000000000001Id tài khoản quảng cáo đã nối (không gồm tiền tố act_).
namebodystringCóMua hàng webTên chuyển đổi.
event_source_idbodystringKhông1000000000000009Id pixel / nguồn sự kiện.
custom_event_typebodystringKhôngPURCHASELoại: PURCHASE · LEAD · ADD_TO_CART · COMPLETE_REGISTRATION · OTHER…
rulebodyobjectKhông{"url":{"i_contains":"cam-on"}}Điều kiện ghi nhận (JSON), vd URL chứa chuỗi.
default_conversion_valuebodynumberKhông0Giá trị mặc định mỗi lần chuyển đổi.
descriptionbodystringKhôngMô tả.

Ví dụ request

curl -s -X POST "https://partner.quantri360.com/v1/facebook/v25.0/act_1000000000000001/customconversions" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Mua hàng web","event_source_id":"1000000000000009","custom_event_type":"PURCHASE","rule":{"url":{"i_contains":"cam-on"}}}'
Python
import requests

KEY = "q360_live_..."  # khóa API của brand
r = requests.post(
    "https://partner.quantri360.com/v1/facebook/v25.0/act_1000000000000001/customconversions",
    params={},
    json={
        "name": "Mua hàng web",
        "event_source_id": "1000000000000009",
        "custom_event_type": "PURCHASE",
        "rule": {
            "url": {
                "i_contains": "cam-on"
            }
        }
    },
    headers={"Authorization": f"Bearer {KEY}"},
    timeout=60,
)
print(r.status_code)
print(r.json())
Node.js
const KEY = 'q360_live_...'; // khóa API của brand
const url = new URL('https://partner.quantri360.com/v1/facebook/v25.0/act_1000000000000001/customconversions');
for (const [k, v] of Object.entries({})) url.searchParams.set(k, typeof v === 'object' ? JSON.stringify(v) : String(v));
const r = await fetch(url, {
  method: 'POST',
  headers: { Authorization: `Bearer ${KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({"name":"Mua hàng web","event_source_id":"1000000000000009","custom_event_type":"PURCHASE","rule":{"url":{"i_contains":"cam-on"}}}),
});
console.log(r.status, await r.json());
PHP
<?php
$key = 'q360_live_...'; // khóa API của brand
$url = 'https://partner.quantri360.com/v1/facebook/v25.0/act_1000000000000001/customconversions' . '?' . http_build_query([]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $key, 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"name":"Mua hàng web","event_source_id":"1000000000000009","custom_event_type":"PURCHASE","rule":{"url":{"i_contains":"cam-on"}}}');
$res = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status, "\n", $res;

Response

Tham số phản hồi (nguyên của Facebook)

TênKiểuMẫuMô tả
idstring1000000000000010Id chuyển đổi tùy chỉnh.

Mẫu phản hồi

{
  "id": "1000000000000010"
}

Bắt đầu dùng

  1. Đăng ký tài khoản Partner
  2. Mở loại dữ liệu thuộc nhóm Quảng cáo (Marketing API) ở trang nền tảng
  3. Tạo API key (tick kênh Facebook)
  4. Gọi theo ví dụ ở trên