Ad data reporting
analytics
1. API Description
API feature: report advertising data
interface declaration: analytics(object: Object): Promise<void>
Note
This API is supported since SDK version 1.4.0 and must be combined with WeChat authorization login when in use.
2. Input Parameters
| field | data type | required | description |
|---|---|---|---|
| report_type | string | yes | reporting type, currently supports "mall" |
| report_data | IReportData | yes | reported content |
IReportData
| field | data type | required | description |
|---|---|---|---|
| action_time | number | no | reporting time, by default if left blank takes the current client time, unit: seconds |
| action_type | string | required | Behavior type, for example visit_store, share, add merchandise to the shopping cart. See reference table action_types for detail type |
| click_id | string | no | The advertising platform will add click_id to the URL. For value type, see (https://ad.weixin.qq.com/guide/457) |
| action_param | IActionParam | no | Parameters of the action |
| product_param | IProductParam | no | Product structure content |
IActionParam
| field | data type | required | description |
|---|---|---|---|
| value | number | no | Parameters of the action, conversion behavior value (such as currency) |
| leads_type | string | no | Action source, currently supports PHONE (call), RESERVE (form) |
IProductParam
| field | data type | required | description |
|---|---|---|---|
| product_yun_type | string | No | Product goods, coupon, search term |
| product_yun_id | string | No | Product ID |
| product_yun_category | string | No | Product category, custom |
| product_yun_keywords | string | No | Product keyword |
| product_yun_price | number | No | Original product 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 ad product library |
| product_yun_category_ad | string | No | Product category in the ad product library |
action_types
| type value | description |
|---|---|
| visit_store | visit |
| share | share |
| consult | consult |
| claim_offer | claim |
| add_to_cart | add merchandise to the shopping cart |
| add_to_wishlist | favorite |
| complete_order | Place Order |
| purchase | Payment |
| search | Search |
| deliver | Shipment |
| sign_in | Acknowledge |
3. Output Parameters
N/A
4. Example code
import cloudbase from "@cloudbase/js-sdk";
// Initialize SDK instance
const app = cloudbase.init({
env: "xxxx-yyy"
});
WeChat authorization login
const provider = auth.weixinAuthProvider({
appid: "...",
scope: "xxxx"
});
provider.getRedirectResult().then((loginState) => {
if (loginState) {
Login is 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"
}
}
});
}
});