How to add Triggers

How to use Triggers to automatically send an In-App Message

The trigger is a custom option for when to show the message. You can trigger the in-app message when the user opens the app or setup a custom triggers programmatically with addTrigger method. Custom triggers are key: value pair of string or integer data that you set programmatically in your app when an event occurs.

For example, if you want to send an in-app message when a user reaches level 5. Each time the use grows a level, you would call for example OneSignal.addTrigger("level", 1); then when they reach level 2, you simply update the trigger OneSignal.addTrigger("level", 2); and so on. At OneSignal.addTrigger("level", 5); the in-app message will show to the user by setting the trigger to level is 5 in the dashboard.

Triggers can be combined with AND and OR operators to only show under very specific conditions.

Select Trigger Conditions

When creating an In-App Message, you can set a trigger action. This enables you to select a trigger which when its state is changed will send the In-App.

Similarly, you can also specify additional behaviors such as the duration since the last In-App Message. This ensures your users are not overwhelmed by too many In-App Messages.

1766

Image showing how you can set a trigger when creating an In-App Message

Below are a series of triggers you can specify.

TriggerDescription
On app openShow message upon next app open.

Use this to make sure all users within the segment get the message when they open the app.
In-App TriggerShow message when user performs certain action.

Message shows when calling the addTrigger method for the corresponding key value pair.
Session DurationShow message after x seconds within the current app session.
Duration Since Last In-AppShow message after x seconds since the most recent in-app message.

When should this message dismiss?

Control how long the message should stay on the screen.

  • Show until dismiss - will show the message until physically acted upon.
  • Dismiss after certain amount of time - set how long the message should show before automatically being removed from screen.

Setup Re-Trigger Options

Navigate to Schedule > How often do you want to show this message?

1766

Image showing the ability to schedule an In-App Message

How often do you want to show this message?

Only once is default. The in-app message will only show 1 time on the current device.

Every time trigger conditions are satisfied will show this message each time the Trigger conditions are met.

Multiple times allows you to set the specific amount of times this message can be shown and how long to wait in between each display.

For example, if you set: "2 times with a gap of 1 hours in between" - The message will be allowed to trigger a total of 2 times. The first time when the triggers are met, then the 2nd time when the triggers are met and 1 hour has passed.

If you set "12 times with a gap of 30 days in between" - The message will show roughly once a month for a year.

🚧

Triggers Must Be Satisfied

If the Trigger is On app open or Session Duration then the user must open the app to see it again.

If trigger is Duration since last in-app then the message will show after this timeframe is satisfied.

If the trigger is a programmatic In-app trigger, then the method must be called again after the "multiple times gap" timeframe is satisfied.

FAQ

Are triggers tags?

The value of the trigger is not viewable within the OneSignal dashboard, but you can view the current trigger value programmatically with the getTriggerValueForKey method on the OneSignal SDK.