Push notifications notify the user of new events in an application. Push notifications are generally created when information is sent by the server in communication with the application.


Tagging example

To tag push notifications, it’s necessary to have an IntentService class. This class will retrieve information from the server for generation of the application’s push notifications. Thanks to this, parameters can be added to the notification.

Example of code for creating a notification containing information:

package com.atinternet.atinternetdemo;

import android.content.Intent;

public class DemoService extends IntentService {

    public DemoService(String name) {

    public void onCreate() {

    protected void onHandleIntent(Intent intent) {
        NotificationCompat.Builder notificationBuilder =
                new NotificationCompat.Builder(this)
                        .setContentText("Notification received");

        Intent notificationIntent = new Intent(getApplicationContext(), DestinationActivity.class);
        notificationIntent.putExtra("xto", "AD-10");
        PendingIntent intent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);

        // Catch Delete Notification event
        Intent deleteIntent = new Intent(this, DismissNotificationReceiver.class);
        PendingIntent pendingDeleteIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, deleteIntent, 0);

        NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

This Intent will then be used by the notification.

NB: In order to tag the deletion of a notification, you have to create a specific BroadcastReceiver

In AndroidManifest.xml:



package com.atinternet;

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

import com.atinternet.tracker.Tracker;

import java.util.HashMap;

public class DismissNotificationReceiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
        // Track Dismiss notification
        Tracker t = new Tracker(context, new HashMap<String, Object>() {
                put("log", "YOURLOG");
                put("logSSL", "YOURSSLLOG");
                put("site", "YOURSITEID");

In the view called during the click on the push notification, it is now possible to retrieve information contained in the notification and therefore tag it.

We retrieve the notification’s Intent and we verify that the desired data exists:

Tracker tracker = ATInternet.getInstance().getDefaultTracker();
if (getIntent().getStringExtra("xto") != null) {

If you wish to simplify the tagging of your links without having to know the significance of each field, try the interface available in our marketplace. Please note that this interface has been created by our community and can be improved, so feel free to send us your feedback!

Last update: 18/05/2018