本文介绍了没有谷歌分析实施的Andr​​oid谷歌播放的广告系列跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何实现谷歌运动追踪系统,而无需使用谷歌Analytics(分析)?

How to implement Google campaign tracking system without using Google analytics ?

我使用mixpanel跟踪的目的

I am using mixpanel for tracking purpose

推荐答案

得到了答案,分享给别人参考

Got the answer and sharing for others Reference

首先要创建一个广播接收器

First have to create a broadcast receiver

public class ReferalIntentReciever extends BroadcastReceiver {
    public static MixpanelAPI mixpanel;

    Context context;

    @Override
    public void onReceive(Context context, Intent intent) {
        mixpanel = MixpanelAPI.getInstance(context, "YOUR MIXPANEL TOKEN");

        // TODO Auto-generated method stub

        String referrerString = intent.getStringExtra("referrer");
       //sending to mixpanel
        try {
            JSONObject props = new JSONObject();
            props.put("utm_source", splitQuery(referrerString)
                    .get("utm_source"));
            props.put("utm_medium", splitQuery(referrerString)
                    .get("utm_medium"));
            if (splitQuery(referrerString).get("utm_campaign") != null) {
                props.put("utm_campaign",
                        splitQuery(referrerString).get("utm_campaign"));
            }
            mixpanel.track("Referral Campaign", props);
            mixpanel.flush();

        } catch (Exception e) {
            e.printStackTrace();
        }


    }

    //getting each parameter

    public static Map<String, String> splitQuery(String url)
            throws UnsupportedEncodingException {
        Map<String, String> query_pairs = new LinkedHashMap<String, String>();
        String[] pairs = url.split("&");
        for (String pair : pairs) {
            int idx = pair.indexOf("=");
            query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"),
                    URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
        }
        return query_pairs;
    }
}

现在必须设置接收器清单文件

now have to set the receiver in manifest file

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

现在的应用程序已经准备好安装后接收意图从Play商店

Now the app is ready for receiving intents from play store after installation

这篇关于没有谷歌分析实施的Andr​​oid谷歌播放的广告系列跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 04:02