1 Applicable analysis model
Event analysis, funnel analysis, retention analysis, and session analysis
2 Use process
2.1 New Report
Click the "Behavior Analysis" module on the homepage of the Quick Tracking platform to go to the "Behavior Analysis" function homepage. On the "Behavior Analysis" homepage, you can use the filter box and search box to quickly find applications that need to export data, as shown in the following figure:
Click "Behavior Analysis"- "Analysis"to enter "Behavior Insight" page, create a report based on the data export requirements.
2.2 Obtain Report ID
Click "More" in the upper right corner of the functional area to enter the "report list", view the saved report, and click "Copy Report ID" to copy it.
2.3 to use OpenAPI to obtain report data
2.3.1 Permission verification
Authentication Basis
API ID and API Secret
Note: Because the data is sensitive, it is only visible in the main account. The specific display location is:
"Management Console"--> "Collecting Information"
.
URL parameters
http://xxx.yyy.com/api/{service}?api_id=abcdef&api_sign=abcdef&api_ts=123456
Parameter name | Description | Remarks |
api_id | API ID | Quick Tracking background master account can be viewed |
api_sign | Signature | For more information, see "Authentication signature". |
api_ts | Timestamp | The timestamp must be the same as the timestamp when the QuickTracking service is deployed. If the timestamp is different from the timestamp when the QuickTracking service receives the request, an error is reported. |
http://xxx.yyy.com/ | Manage domain on the front page | After logging in to Quick Tracking, the browser foreground displays the domain name. |
body parameter
{
"dataSourceId": "32772108106530",
"reportId":"rh2m151qj7bmh67uiqv46il4vfn8vckc",
"timeUnit":"day",
"fromDate":"2021-12-01",
"toDate": "2021-12-23"
}
Authentication signature
Sort method names and parameters alphabetically by key
/**
* Quick Tracking background master account can be viewed
*/
String secret = "abcdef";
/**
* The name of the service to be requested.
*/
String service = "analysis.report.data";
/**
* 1. Obtain URL parameters, such as apiId=abcdef&sign=abcdef&ts=123456.
* 2. Sort by key and remove the sign. The result is apiId=abcdef&ts=123456.
*/
String queryString = sort("api_id=abcdef&api_ts=123456");
/**
* POST interface, body content
*/
String bodyString = "{
"dataSourceId": "32772108106530",
"reportId":"rh2m151qj7bmh67uiqv46il4vfn8vckc",
"timeUnit":"day",
"fromDate":"2021-12-01",
"toDate": "2021-12-23"
}";
String source = service
+ "\n"
+ queryString
+ "\n"
+ bodyString;
Use an API Secret to encrypt source data
String sign = new HmacUtils(HmacAlgorithms.HMAC_SHA_1, secret).hmacHex(source);
sign = 1cfc10a297397e91f1e50e1f41ac24b8c45fd53d
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.3.0</version>
</dependency>
package com.alibaba.umeng.base.product.advanced.controller;
import com.alibaba.fastjson.JSONObject;
import okhttp3.*;
import org.apache.commons.codec.digest.HmacAlgorithms;
import org.apache.commons.codec.digest.HmacUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
/**
* @author mingpeng.spc
* @date 2022/01/07
*/
public class OpenApiControllerTest {
private static final MediaType APPLICATION_JSON = MediaType.parse("application/json; charset=utf-8");
private final static Logger LOGGER = LoggerFactory.getLogger(OpenApiControllerTest.class);
public static void main(String[] args) {
String URL = "http://pre.aplus.emas-poc.com/api/";
String service = "analysis.report.data";
String apiId = "avWYU24hvdl62V8p";
String apiSecret = "xezIgkcrtZ2yLQA4LYgBuyUo6Re2hCu8";
/**
* Construct URL parameters.
*/
String query = new StringBuilder()
.append("api_id=").append(apiId)
.append("&")
.append("api_ts=").append(System.currentTimeMillis())
.toString();
/**
* Construct the body parameter.
*/
JSONObject body = new JSONObject();
body.put("dataSourceId", "69412108036695");
body.put("reportId", "7f6o7no8gks3uebieto2lmlv6o6728bj");
body.put("timeUnit", "day");
body.put("fromDate", "2021-12-31");
body.put("toDate", "2022-01-06");
String bodyString = body.toJSONString();
/**
* service
* query
* body
*/
StringBuilder valueToDigest = new StringBuilder()
.append(service)
.append("\n")
.append(query)
.append("\n")
.append(bodyString);
String sign = new HmacUtils(HmacAlgorithms.HMAC_SHA_1, apiSecret).hmacHex(valueToDigest.toString());
try {
Response response = post(URL + service + "?" + query + "&api_sign=" + sign, bodyString);
System.out.println(response.body().string());
} catch (Exception e) {
LOGGER.info("invoke post error", e);
}
}
/**
* HTTP Post
* @param URL URL
* @param body The request body.
* @return
*/
private static Response post(String URL, String body) throws IOException {
LOGGER.info("http post start, URL = {}, body = {}", URL, body);
RequestBody requestBody = RequestBody.create(APPLICATION_JSON, body);
Request request = new Request.Builder()
.URL(URL)
.post(requestBody)
.build();
Response response = new OkHttpClient().newCall(request).execute();
LOGGER.info("http post success");
return response;
}
}
.
2.3.2 Data acquisition
Request:
Field | Type | Required | Description |
dataSourceId | String | Required | |
reportId | String | Required | report id |
timeUnit | String | Required | hour/day/week/month |
fromDate | String | Required | yyyy-MM-dd |
toDate | String | Required | yyyy-MM-dd |
You can use the following method to obtain the dataSourceId:
Open the report to be exported. In the page URL, the number after platform is dataSourceId;
Alternatively, you can right-click and select "Check" ->"Network" to see the dataSourceId.
{
"dataSourceId":"74612111122219",
"reportId":"on3t8cosv298bt80it2st38o562ga95u",
"timeUnit":"day",// The granularity of the request is hourly. The value of the fromDate parameter must be equal to the value of the toDate parameter.
"fromDate":"2021-12-08",
"toDate":"2021-12-14"
}
Sample response:
{
// Return the date.
"date":[
"2021-12-08",
"2021-12-09",
"2021-12-10",
"2021-12-11",
"2021-12-12",
"2021-12-13",
"2021-12-14"
],
// The name of the group.
"groupNames":[
],
// The name of the metric.
"indicatorNames":[
"Number of invited clicks",
"Successful invitation to receive rewards",
"Invitation Success Conversion Rate"
],
"firstTitle":"Metric name",
"total":3,
// Return data.
"data":[
[ // The returned result data of metric 1
"Number of invited clicks", // The name of the metric.
1501, // the total result of indicator one in the selected time range
162, // minimum date result data
547,
176,
187,
128,
237,
183 // maximum (near) date result data
],
[
// The returned result data of metric 2.
"The invitation is successful.",// The name of metric 2.
185, // Total result of metric 2 in the selected time range
28, // Minimum date result data
67,
11,
14,
17,
32,
16 // Maximum (near) date result data
],
[
// The returned result data of metric 3.
"Successful invitation conversion rate",
0.1232, // Total result of metric 2 in the selected time range
0.1728, // minimum date result data
0.1224,
0.0625,
0.0748,
0.1328,
0.135,
0.0874 // maximum (near) date result data
]
],
"groupKeys":[
],
"groupTitle":[
]
}