本文通过对flutter_matomo提供的对外API接口,了解能用它来实现哪些功能
相关资料
flutter_matmo接口解析
以下方法都是flutter项目中所能使用的matomo方法
- 初始化SDK
/// 参数url: matomo部署的服务器路径(如:https://YOUR_URL/piwik.php)
/// 参数siteId 在matomo客户端中设置的用于flutter客户端的站点ID
static Future<String> initializeTracker(String url, int siteId);
- 追踪屏幕
/// 参数widgetName 页面名称(如:登录页、首页、个人中心等等)
/// 参数eventName 定义事件名称(如:进入页面、离开页面)
static Future<String> trackScreenWithName(String widgetName, String eventName)
- 追踪事件
/// 参数widgetName 触发事件的入口(如登录按钮、定义按钮、分享按钮等等)
/// 参数eventName 事件名称(如登录事件、订阅事件、分享事件、开启定时关闭事件等等)
/// 参数eventAction 事件动作(可以传入该事件相关的一系列数据,如登录事件中的用户名、密码、登录时间、设备等等)
static Future<String> trackEventWithName(String widgetName, String eventName, String eventAction)
- 跟踪应用下载(仅在ANDROID上)
///官方解释,大意是记录app的下载次数,一般情况下一个设备上每个版本只记录一次
/**
* Sends a download event for this app.
* This only triggers an event once per app version unless you force it.<p>
* {@link Download#force()}
* <p class="note">
* Resulting download url:<p>
* Case {@link org.matomo.sdk.extra.DownloadTracker.Extra.ApkChecksum}:<br>
* http://packageName:versionCode/apk-md5-checksum<br>
* <p>
* Case {@link org.matomo.sdk.extra.DownloadTracker.Extra.None}:<br>
* http://packageName:versionCode<p>
*
* @return this object, to chain calls.
*/
static Future<String> trackDownload();
- 根据ID追踪目标
///官方解释,大意是在matomo客户端中设置一个特定目标ID, 客户端在触发这个目标时,调用该方法,传入该ID
/**
* By default, Goals in Matomo are defined as "matching" parts of the screen path or screen title.
* In this case a conversion is logged automatically. In some situations, you may want to trigger
* a conversion manually on other types of actions, for example:
* when a user submits a form
* when a user has stayed more than a given amount of time on the page
* when a user does some interaction in your Android application
*
* @param idGoal id of goal as defined in matomo goal settings
*/
static Future<String> trackGoal(int goalId)
网友评论