Android Analytics广告系列跟踪

时间:2013-12-06 15:51:11

标签: android api google-analytics analytics

我想知道我的Android用户如何进入我的应用程序的Play商店链接。 为此,我集成了Google AnalyticsAPI,但未调用安装意图,我无法在使用google play url builder

构建的链接中获取utm_source,utm_campaign ...参数

所以我试图用我的自定义意图这样做:

1:android清单:

<receiver android:name="com.appehour.InstallReceiver" android:exported="true">
      <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER"  android:exported="true"/>
      </intent-filter>
    </receiver>

2:InstallReceiver类

public class InstallReceiver extends BroadcastReceiver {

private String 
    utm_compaign , 
    utm_source, 
    utm_medium, 
    utm_term, 
    utm_content,
    deviceId;

private static String url, installTimeStamp;
public static final String PREF_TRACK_INSTALL_RECEIVER_DATAS = "datas_receiver_install",
        PREF_DEVICE_ID = "pref_device_id",
        PREF_COMPAIGN = "pref_compaign",
        PREF_SOURCE = "pref_source",
        PREF_MEDIUM = "pref_medium",
        PREF_TERM = "pref_term",
        PREF_CONTENT = "pref_content",
        PREF_INSTALL_TIME_STAMP = "pref_install_time_stamp",
        PREF_DATA_STORED = "pref_datas_stored";

protected JSONObject jsonSend , jsonObjRecv;
private boolean installParamsSend = false;



@SuppressLint("NewApi")
@Override
public void onReceive(Context context, Intent intent) {


    TimeZone timeZone = TimeZone.getDefault();

    installTimeStamp = String.valueOf(System.currentTimeMillis()) ;
    deviceId = Secure.getString(context.getContentResolver(),Secure.ANDROID_ID);


    //****************************** Tris des datas reçus par le brodcast ********************************//

    String referrer = intent.getStringExtra("referrer");

    //the paramters are separated by this : %3D
    // uriTokens store all the paramaters with her value
    String[] uriTokens = referrer.split("%3D");
    for(int i=0;i<uriTokens.length;i++){

        //the parameter name and the value are separated 
        String[] valTokens = uriTokens[i].split("%26");

        if (valTokens[0].equals("utm_compaign"))
            utm_compaign = valTokens[1];
        else if (valTokens[0].equals("utm_source"))
            utm_source = valTokens[1];
        else if (valTokens[0].equals("utm_medium"))
            utm_medium = valTokens[1];
        else if (valTokens[0].equals("utm_term"))
            utm_term = valTokens[1];
        else if (valTokens[0].equals("utm_content"))
            utm_content = valTokens[1];
    }


    //******************************************************************************************************//

    Log.d(InstallReceiver.this.getClass().getSimpleName(), 
            "utm_compaign = "+utm_compaign+
            "| utm_source = "+utm_source+
            "| utm_medium = "+utm_medium+
            "| utm_term = "+utm_term+
            "| utm_content = "+utm_content+
            "| device_id = "+deviceId+
            "| installTimeStamp ="+installTimeStamp);

当我使用adb shell模拟应用安装时:

adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.appehour.jdm/com.appehour.InstallReceiver --es  "referrer" "utm_source%26testSource%3Dutm_compaign%268656"

我得到了我的数据。但是,当我将我的应用程序放在商店上时,数据无法恢复。

知道问题是什么吗?

由于

0 个答案:

没有答案