我们几乎完成了为我们的文件托管服务开发应用程序。该应用程序的主要用途是在我们托管的文件中搜索引擎,但 Google Analytics Mobile 没有类似于站点搜索设置的功能。
有人知道如何跟踪搜索词吗?
目前我只坚持将搜索查询作为屏幕名称推送,例如:mGaTracker.sendView("/search/SearchTerm")
并在一个配置文件上收集这些数据并在另一个配置文件上过滤它。还有其他想法吗?
我们几乎完成了为我们的文件托管服务开发应用程序。该应用程序的主要用途是在我们托管的文件中搜索引擎,但 Google Analytics Mobile 没有类似于站点搜索设置的功能。
有人知道如何跟踪搜索词吗?
目前我只坚持将搜索查询作为屏幕名称推送,例如:mGaTracker.sendView("/search/SearchTerm")
并在一个配置文件上收集这些数据并在另一个配置文件上过滤它。还有其他想法吗?
尝试这个 :-
private Tracker tracker;
// write code in on create of your activity
tracker = GoogleAnalyticEntity.getInstance().getTracker();
//code for event
tracker.sendEvent(ConstantLib.HmeScreen, ConstantLib.PreLoginScreen,
"", 0l);
GoogleAnalyticEntity 的代码:-
import android.app.Activity;
import android.content.Context;
import com.google.analytics.tracking.android.EasyTracker;
import com.google.analytics.tracking.android.Tracker;
public class GoogleAnalyticEntity {
public Tracker tracker;
Context context;
public static EasyTracker easytracker;
private static GoogleAnalyticEntity instance;
public static GoogleAnalyticEntity getInstance() {
if (null == instance) {
instance = new GoogleAnalyticEntity();
}
return instance;
}
public static void setInstance(GoogleAnalyticEntity instance) {
GoogleAnalyticEntity.instance = instance;
}
public Context getContext() {
return context;
}
public void setContext(Context context) {
EasyTracker.getInstance().setContext(context);
this.context = context;
}
public void startTracker(Activity activity) {
EasyTracker.getInstance().activityStart(activity);
}
public void StopTracker(Activity activity) {
EasyTracker.getInstance().activityStop(activity);
}
public static EasyTracker getEasytracker() {
if (easytracker == null) {
easytracker = EasyTracker.getInstance();
}
return easytracker;
}
public Tracker getTracker() {
if (tracker == null) {
tracker = EasyTracker.getTracker();
}
return tracker;
}
public static void setEasytracker(EasyTracker easytracker) {
GoogleAnalyticEntity.easytracker = easytracker;
}
public void setTracker(Tracker tracker) {
this.tracker = tracker;
}
public void sentevent(Context mContext, String category, String label,
String action, long val) {
tracker.sendEvent(category, action, label, val);
}
}
在 values 文件夹中创建 analytics.xml:-
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Replace placeholder ID with your tracking ID -->
<string name="ga_trackingId">UA-4XXXXXXX-1</string>
<!-- Enable Activity tracking -->
<bool name="ga_autoActivityTracking">true</bool>
<!-- Enable debug -->
<bool name="ga_debug">true</bool>
<!-- The screen names that will appear in your reporting -->
<string name="com.test.screen.PreLoginActivity">PreLogin Screen</string>
<!--
The inverval of time after all the collected data
should be sent to the server, in seconds.
-->
<integer name="ga_dispatchPeriod">30</integer>
</resources>