We live in a mobile-oriented world so it’s crucial to provide the best usability experience possible. In this post we show how you can preserve user’s context when installing a mobile application from a website.


Have you ever seen this comic?

xkcd comic
(source: http://xkcd.com/869/)

Even though web developers did their homework, it is still a common scenario to install an application and just lose context of where you were just before.

Let’s say a user is browsing through offers on a real estate page. She notices a banner at the top which advertises her to install a mobile application.

banner advertising possibility to install a mobile application

She clicks it, opens Google Play Store, installs an application and totally loses content she saw at the beginning of the whole process.


Fortunately, there is a solution for maintaining context. To do so, we would use Campaign Parameters passed to Google Play Link.

In this example we would use utm_term for passing the id of the offer we want to be shown.

On every page with application advertisement we add this parameter with the corresponding id of the real estate property.

So our link for id 12345 looks like this:


When application is installed from Google Play, broadcast is emitted with data from the referrer. We implement and register a custom broadcast receiver, capture utm_term and display the offer within our application.

Our broadcast receiver:

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.google.common.base.Splitter;
import com.google.common.primitives.Ints;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class PlayServicesUtmReceiver extends BroadcastReceiver {

    public void onReceive(Context context, Intent intent){
        if (intent.hasExtra("referrer")) {
            String utmTerm = getUtmTerm(intent);
            if (utmTerm != null && Ints.tryParse(utmTerm) != null) {
                // Start detail Activity here with id from utmTerm

    private String getUtmTerm(Intent intent) {
        try {
            return Splitter.on("&").withKeyValueSeparator("=")
                    .split(URLDecoder.decode(intent.getStringExtra("referrer"), "UTF-8")).get("utm_term");
        } catch (UnsupportedEncodingException e) {
            // TODO handle unsupported exception here
        return null;



Using this trick you will be able to maintain context between application and mobile website. It will provide better experience to your users. We hope that you find it useful.