I have a simple task: I want to track the referral id of an app install and pass it to backend.
What I did: I created a link with an extra parameter referrer
I have used utm tagging
you can see full source at https://github.com/dheeraj9198/Utm-Test
I am providing the basic code
public class CustomCampaignTrackingReceiver extends BroadcastReceiver {
private static final String TAG = CustomCampaignTrackingReceiver.class.getSimpleName();
private static final Logger LOGGER = LoggerFactory.getLogger(TAG);
private static final Marker MARKER = MarkerFactory.getMarker(TAG);
@Override
public void onReceive(Context context,final Intent intentx) {
LOGGER.info(MARKER, "on Receive called");
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@Override
public void run() {
try {
for (String key : intentx.getExtras().keySet()) {
try {
LOGGER.info(MARKER, key + " => " + String.valueOf(intentx.getExtras().get(key)));
} catch (Exception e) {
LOGGER.error(MARKER, "caught exception in on key retrieval ", e);
}
}
} catch (Exception e) {
LOGGER.error(MARKER, "caught exception in key loop ", e);
}
}
});
executorService.shutdown();
}
}
--------------------------Manifest---------------------------------------