0
@Override
            public void onClick(DialogInterface dialog, int whichButton) {
                // User clicked buy pro 
                Tracker tracker = EasyTracker.getTracker();
                Map<String, String> params = new HashMap<String, String>();
                params.put("action", "confirm");
                tracker.send("proVersionTracker", params);
                ........
            }

我点击了这个按钮几次,等了 5 分钟,检查了谷歌分析事件,那里什么都没有。我做错了什么还是事件显示需要超过 5 分钟?

4

1 回答 1

2

还需要一些其他的东西。

首先,您需要使用以下资源文件设置您的 trackingId:

<resources>
<!--Replace placeholder ID with your tracking ID-->
<string name="ga_trackingId">UA-00000000-3</string>

<!--Enable automatic activity tracking-->
<bool name="ga_autoActivityTracking">true</bool>

<!--Enable automatic exception tracking-->
<bool name="ga_reportUncaughtExceptions">true</bool>
</resources>

同样在您的活动中,您需要以下内容:

@Override
protected void onStop() {
    super.onStop();
    analytics.stop(this);
}

@Override
protected void onStart() {
    super.onStart();
    analytics.start(this);
}

我在这里的实用程序类中定义了这些:

/**
 * 
 */
package co.uk.benbun.nvrrclubapp.utils;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import com.google.analytics.tracking.android.EasyTracker;
import com.google.analytics.tracking.android.GAServiceManager;

/**
 * @author RichardKavanagh
 * 
 */
public class analytics {

public static void raiseEvent(Context context, String a, String b, String c, String makeToast) {

    String msg = a + " : " + b + " : " + c;
    EasyTracker.getTracker().sendEvent(a, b, c, null);
    GAServiceManager.getInstance().dispatch();

    Log.i("Analytics", msg);

    if (makeToast.equals("Y")) {
        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
    }

}


public static void start(Activity activity) {
    EasyTracker.getInstance().activityStart(activity);
}

public static void stop(Activity activity) {
    EasyTracker.getInstance().activityStop(activity);
}

}

于 2013-05-17T17:11:05.740 回答