Skip to main content

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

fielddata typerequireddescription
report_typestringyesreporting type, currently supports "mall"
report_dataIReportDatayesreported content
IReportData
fielddata typerequireddescription
action_timenumbernoreporting time, by default if left blank takes the current client time, unit: seconds
action_typestringrequiredBehavior type, for example visit_store, share, add merchandise to the shopping cart. See reference table action_types for detail type
click_idstringnoThe advertising platform will add click_id to the URL. For value type, see (https://ad.weixin.qq.com/guide/457)
action_paramIActionParamnoParameters of the action
product_paramIProductParamnoProduct structure content
IActionParam
fielddata typerequireddescription
valuenumbernoParameters of the action, conversion behavior value (such as currency)
leads_typestringnoAction source, currently supports PHONE (call), RESERVE (form)
IProductParam
fielddata typerequireddescription
product_yun_typestringNoProduct goods, coupon, search term
product_yun_idstringNoProduct ID
product_yun_categorystringNoProduct category, custom
product_yun_keywordsstringNoProduct keyword
product_yun_pricenumberNoOriginal product price
product_yun_valuenumberNoProduct transaction price
product_yun_namestringNoProduct name
product_yun_id_adstringNoProduct ID in the ad product library
product_yun_category_adstringNoProduct category in the ad product library
action_types
type valuedescription
visit_storevisit
shareshare
consultconsult
claim_offerclaim
add_to_cartadd merchandise to the shopping cart
add_to_wishlistfavorite
complete_orderPlace Order
purchasePayment
searchSearch
deliverShipment
sign_inAcknowledge

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"
}
}
});
}
});