2
votes

Google Analytics is storing the information I pass in the URL with utm_source, utm_campaign, and utm_medium. Now I am wondering how I grab that information when the user opens the application? I see this in my logs:'

03-18 20:19:48.633: I/GAV2(32317): Thread[GAThread,5,main]: Campaign found: utm_source=source value tracking tara&utm_medium=medium value tracking tara&utm_campaign=campaign value tracking tara androidlitetrackingtara

I have this in my applications manifest:

<service android:name="com.google.analytics.tracking.android.CampaignTrackingService" />

        <receiver
            android:name="com.google.analytics.tracking.android.CampaignTrackingReceiver"
            android:exported="true" >
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>

I try to grab it from the intent, but the data is not there. Any ideas?

2
I have the same problem. Any luck? - Stefan Anca

2 Answers

0
votes

Make sure you are using the v3 SDK. Here is the instruction page:

https://developers.google.com/analytics/devguides/collection/android/v3/campaigns

If the INTENT_REFERRER doesn't work then try the Map example given later in the page.

Also, make sure you are giving enough time between downloading the app and the data showing up in GA. It can take up to ~24 hours for GA to show data.

0
votes

Create your own broadcast receiver. Store data and pass it to google analytic later

public class InstallReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    Log.d("InstallReceiver", "onReceive");

    try {
        // get referrer value

        Bundle extras = intent.getExtras();
        if (extras != null) {

            GoogleAnalytics.getInstance(context).getLogger().setLogLevel(LogLevel.VERBOSE);
            String referrerValue = extras.getString("referrer");
// Handle data. Save it


            Log.d("InstallReceiver", "referrerValue=" + referrerValue);
            String afterDecode = URLDecoder.decode(referrerValue, "UTF-8");
            String[] temp = afterDecode.split("&");
            String agencyId = temp[0].replace("utm_source=", "");


            Utils.saveAgencyId(context.getApplicationContext(), agencyId);

// transfer intent to google receiver.


            new CampaignTrackingReceiver().onReceive(context, intent);
        }

    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
}