📝[SCRIPT] - Ghi nhận đơn hàng Cost per Lead (CPL)
Đối tác cần đặt script trên vào trang phù hợp (ví dụ: trang đặt hàng thành công) để có thể ghi nhận đúng mã đơn hàng và giá trị đơn hàng.
<script>
function sendPostback (transaction_id, sale_amount) {
var clickId = getCookie ('mo_traffic_id');
// Đối tác tự xử lý việc lấy transaction_id và sale_amount tại đây
let url = `http://s2s.dev.masoffer.tech/v1/${offer_id}/postback.json?api_key=${signature}&offer_type=cpl_one_postback&transaction_id=${transaction_id}&click_id=${clickId}&status_code=0&sale_amount=${sale_amount}`; // Postback Development
// let url = `https://s2s.masoffer.net/v1/${offer_id}/postback.json?api_key=${signature}&offer_type=cpl_one_postback&transaction_id=${transaction_id}&click_id=${clickId}&status_code=0&sale_amount=${sale_amount}`; // Postback Production
let xhttp = new XMLHttpRequest();
xhttp.open('GET', url);
xhttp.onreadystatechange = function () {
if (xhttp.readyState == XMLHttpRequest.DONE) {
let rs = JSON.parse(xhttp.responseText);
if (rs.status_code == 200) {
document.cookie = "mo_traffic_id=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; // Xóa cookie
}
}
}
xhttp.setRequestHeader('Content-Type', 'application/JSON');
xhttp.send();
}
sendPostback (transaction_id, sale_amount); // Đối tác cần tùy chỉnh giá trị các tham số của hàm sendPostback.
</script>
Giải thích ý nghĩa các tham số
Tham số
Mô tả
Loại
Bắt buộc
offer_id
Id của đối tác do MasOffer cung cấp.
String
api_key
API Key của đối tác do MasOffer cung cấp
String
transaction_id
Mã đơn hàng của đối tác.
String
click_id
ID của traffic do MasOffer cung cấp qua Tracking Link (đã lưu trong cookie).
String
status_code
Trạng thái xử lý đơn hàng:
0: đang xử lý
1: đã mua thành công
-1: đã hủy
Number
sale_amount
Giá trị đơn hàng (sau khuyến mãi nếu có)
Number
Trong trường hợp cập nhật trạng thái đơn hàng, đối tác bắn postback lại như cách https://masoffer.atlassian.net/wiki/spaces/moti/pages/18120778 , tuy nhiên thay đổi giá trị trường status_code.
Response
Last updated