In-App 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 display an in-app message when the user opens the app, or either set up a custom trigger through the In-App Message editor in the dashboard or programmatically with addTrigger method. Custom triggers are key: value pairs of a string data.

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

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

A few things to note:

  • Keys and values are space and case sensitive.
  • The is not trigger needs to be used alongside the exists trigger.

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 Message.

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 using the "is not" trigger, be sure to include "exists" as well.

This ensures that if there is a condition where the value is empty, that the condition is still excluded. For example, if you want to only show a message to "app_version is not 5", adding "app_version exists" ensures those without an app_version will not see the message.

Set message dismissal

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

Set when and how many times the message shows

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?

Triggers do not need to be existing tags. The value of a trigger is not viewable within the OneSignal dashboard.