Anti-Spam

The user experience implemented by an app on receipt of a Trigger payload may not always be relevant to the user, it may be that it doesn't fall in line with a user's preferences or that they have already triggered that user experience in the app and it is not relevant to them again.

It's important in situations like this that the user does not perceive the experience as spam as this could adversely affect their perception of the app.

Rate Statistics

In order to help app developers create a strategy to avoid this perception of spam the TapPoint SDK reports to apps how many times a payload has been reported to an app over the last seven days, the statistics reported are:

FieldDescription
Last Event TimestampThe last time an event involving a trigger with this payload was reported to the application.
Events In The Last HourThe number of events reported to the application involving triggers with this payload in the last 60 minutes.
Events In The Last DayThe number of events reported to the application involving triggers with this payload in the last 24 hours.
Events In The Last WeekThe number of events reported to the application involving triggers with this payload in the last 7 days.

Below is an example of how these statistics are reported to an app as a user interacts with Triggers.

Monday 09:04 a user interacts with a Trigger for the first time on their way to work.

Monday 17:15 the same user interacts with a Trigger with the same payload.

Tuesday 10:13 the same user interacts with a Trigger with the same payload.

The rate statistics are accessible on the Trigger object provided by the TapPoint SDK whenever a trigger occurs.

iOS Trigger Object - Rate Statistics Property

Android Trigger Object - Rate Statistics Property

Writing an Anti-Spam Rule

By using the rate statistics provided by the TapPoint SDK developers can enforce rules within their app to ensure that the user experience is not perceived as spam.

As an example the following code snippets enforce a rule to ensure that a user experience is only triggered once per calendar day.

Android


public void processDetectedTrigger(Trigger trigger) {

	if (shouldTriggerUserExperience(trigger.rateStats())) {
		// Go ahead and trigger the user experience.
	}
	else {
		// Our rate limit rule prevents us from triggering the user experience.
	}
}

public boolean shouldTriggerUserExperience(TriggerRateStats rateStats) {

   // We allow the UX if we haven't triggered it in the last 24 hours...
   // and haven't exceeded more than five times this week.
   shouldTriggerUX = ((rateStats.getEventsInTheLastDay() == 1) && (rateStats.getEventsInTheLastWeek() < 5));

	return shouldTriggerUX;
}

iOS

- (void)processDetectedTrigger:(NSNotification *)notification
{
   NSLog(@"TapPoint Triggers Detected!");

   PRXTrigger *trigger = [notification.userInfo objectForKey:PRXDetectedTriggerNotificationKeyForTrigger];

   if ([self shouldTriggerUserExperience:trigger.rateStatistics]) {
      // Go ahead and trigger the user experience.
   }
   else {
      // Our rate limit rule prevents us from triggering the user experience.
   }
}

(BOOL)shouldTriggerUserExperience:(PRXTriggerRateStatistics *)rateStats
{
   // We allow the UX if we haven't triggered it in the last 24 hours...
   // and haven't exceeded more than five times this week.
   BOOL shouldTriggerUX = ((rateStats.eventsInTheLastDay == 1) && (rateStats.eventsInTheLastWeek < 5));

   return shouldTriggerUX;
}