Advertising Data Reporting
analytics
1. Interface Description
Function: Advertising Data Reporting
Interface declaration: analytics(object: Object): Promise<void>
Note
This interface is supported since SDK version 1.4.0 and must be used in conjunction with WeChat authorized login.
2. Input Parameters
Field | Type | Required | Description |
---|---|---|---|
report_type | string | Required | Reporting type, currently supports "mall" |
report_data | IReportData | Required | Reported content |
IReportData
Field | Type | Required | Description |
---|---|---|---|
action_time | number | No | Reporting time; if not filled, defaults to the current client time in seconds. |
action_type | string | Required | Action type, e.g., visit_store, share, add_to_cart, etc. For detailed types, refer to the table action_types |
click_id | string | Optional | The advertising platform adds click_id to the URL. Value retrieval method: Reference |
action_param | IActionParam | No | Parameters associated with the action |
product_param | IProductParam | No | Product structure details |
IActionParam
Field | Type | Required | Description |
---|---|---|---|
value | number | No | The value of the conversion action (e.g., amount) carried as a parameter by the action. |
leads_type | string | No | Lead source; currently supports PHONE (direct call), RESERVE (form reservation) |
IProductParam
Field | Type | Required | Description |
---|---|---|---|
product_yun_type | string | No | Product type: goods (commodity), coupon (discount coupon), search_term (search term) |
product_yun_id | string | No | Product id |
product_yun_category | string | No | Custom product category |
product_yun_keywords | string | No | Product keywords |
product_yun_price | number | No | Product original price |
product_yun_value | number | No | Product transaction price |
product_yun_name | string | No | Product name |
product_yun_id_ad | string | No | Product id in the advertising product library |
product_yun_category_ad | string | No | Product category in the advertising product library |
action_types
Type Value | Description |
---|---|
visit_store | Access |
share | Share |
consult | Consult |
claim_offer | Coupon claiming |
add_to_cart | Add to Cart |
add_to_wishlist | Add to Wishlist |
complete_order | Place Order |
purchase | Pay |
search | Search |
deliver | Delivery |
sign_in | Confirm Receipt |
3. Output Parameters
None
4. Sample Code
import cloudbase from "@cloudbase/js-sdk";
//Initialize the SDK instance
const app = cloudbase.init({
env: "xxxx-yyy"
});
// WeChat OAuth Login
const provider = auth.weixinAuthProvider({
appid: "...",
scope: "xxxx"
});
provider.getRedirectResult().then((loginState) => {
if (loginState) {
// Login successful!
app.analytics({
report_type: "mall",
report_data: {
action_type: "visit_store",
action_param: {
value: 100
},
product_param: {
product_yun_type: "goods",
product_yun_id: 1,
product_yun_keywords: "UNIQLO",
product_yun_price: 200,
product_yun_value: 100,
product_yun_name: "UNIQLO Utee-Disney"
}
}
});
}
});