Dealing with data campaigns

Since version 1.10.0 we support geotriggers. A geotrigger is used to see if users enter or exit a geofence. It works the same as a geofence notification, but does not display anything on the device of the user. You can use the geotrigger handler to call custom code inside your app, which allows you to create events depending on your app users location. Geotriggers are also available for iBeacons.

Please note that due to restrictions in iOS dwelling time is not supported for geotriggers, we do support it for Android. A full overview of the supported features can be found here.

We have blogged about how to use the geotrigger handler here.

Data Campaigns

Data campaigns is our new term to describe campaigns that are not used to show Notifications to the users’ devices as opposed to Notification campaigns. They only gather insights concerning the user’s location activity.

Data campaigns include two sub-types of campaigns. Those are Listening campaigns and Attribution campaigns.

Listening campaigns represent the previously called Geotrigger campaigns. More information about the Attribution campaigns can be found in the Attribution Campaign Guide.

Data Campaigns

Geotrigger handling

Note

It's important to keep in mind that on the device side all data campaigns notifications are called geotriggers.

Android

When you want to handle your geotriggers, or use them as trigger events for your own code, you can use the geotrigger handler. Plot automatically detects whether a service is registered in AndroidManifest.xml that extends from the class GeotriggerHandlerBroadcastReceiver. Implementations of GeotriggerHandlerReceiver must implement the method public List<Geotrigger> handleGeotriggers(List<Geotrigger> geotriggers). When the service is defined, Plot will send the geotriggers to this method before considering them as handled. This allows you to add custom code that is triggered by entering (or exiting) a geofence or beacon region.

//Example implementation for handleGeotriggers:
public class MyGeotriggerHandlerReceiver extends GeotriggerHandlerBroadcastReceiver {
    @Override
    public List<Geotrigger> handleGeotriggers(List<Geotrigger> geotriggers) {
        List<Geotrigger> passedGeotriggers = new ArrayList<Geotrigger>();
        for (Geotrigger geotrigger : geotriggers) {
            String data = geotrigger.getData();
            if (data.equals("pass")) {
                passedGeotriggers.add(geotrigger);
            }
        }
        return passedGeotriggers;
    }
}

And add this receiver to the manifest:

<receiver android:name=".MyGeotriggerHandlerReceiver" android:exported="false">
    <intent-filter>
        <action android:name="${applicationId}.plot.HandleGeotriggers" />
    </intent-filter>
</receiver>

You can read all fields from a geotrigger just as you would do that for a notification in the notification filter. Full reference for this can be found in the library reference.

Appcelerator

When you want to handle your geotriggers, or use them as trigger events for your own code, you can use the geotrigger handler. To enable the geotrigger handler, you add the property geotriggerHandlerEnabled with the value true to object passed to initPlot. When the geotrigger handler is disabled all geotriggers will be counted as handled.

You define the handler in assets/plotgeotriggerhandler.js. When Plot detects that a geotrigger has triggered, it executes the script. The script runs in a different context than the normal scripts are executed. Therefore you cannot reference views or global variables from the geotrigger handler.

You can remove geotriggers from the array you don't want to mark as handled. Always call plot.popGeotriggers() and plot.markGeotriggersHandled(geotriggers).

An example for assets/plotgeotriggerhandler.js:

var plot = require('com.plotprojects.ti');

Ti.API.info('Plot version: ' + plot.version);

var geotriggersHandler = plot.popGeotriggers();
var geotriggersPassed = [];

for (var i = 0; i < geotriggersHandler.geotriggers.length; i++) {
    var geotrigger = geotriggersHandler.geotriggers[i];
    if (geotrigger.data == "pass") {
        geotriggersPassed.push(geotrigger);
    }

    Ti.API.info(JSON.stringify(geotrigger));
}

geotriggersHandler.geotriggers = geotriggersPassed;

//always call plot.markGeoTriggersHandled function, even if geotriggersPassed becomes empty
plot.markGeoTriggersHandled(geotriggersHandler);

Phonegap

You can see how to implement a geotrigger handler for Phonegap/Cordova/Ionic at How to implement NotificationFilter and GeotriggerHandler for Phonegap/Cordova/Ionic .