# In-App Experience Triggers

A trigger is an event that causes an In-App Automation or Scene to appear in a mobile app. Scenes also support mobile web browsers.

You can configure triggers in an in-app experience [Composer](https://www.airship.com/docs/reference/glossary/#composer) or the [Journey Map](https://www.airship.com/docs/reference/glossary/#journey_map). In the map, you also have the option to complete the same configuration as in the composers' Audience step.

## Configuring triggers in a composer

In the Behavior step of a composer, select and configure a [trigger](#triggers). Select **Add another** to add another trigger. Multiple triggers are handled as a boolean OR.

Next, configure options:
1. Specify [cancellation events](#cancellation-events).
1. [Set a tag](#set-a-tag) when the message is displayed.
1. Set [display conditions](#display-conditions). If you set a cancellation event, you must configure at least one display condition.

You can now select the next step in the composer.

> **Important:** Other than setting a tag, you cannot add, edit, or remove triggers or any part of the composer Behavior step after the in-app experience is made active or while it is paused.


## Configuring triggers and audience in the Journey map

![Configure an In-App Automation or Scene trigger and audience](https://www.airship.com/docs/images/journey-map-trigger-compose_hu_260abb0a03edbdd8.webp)

*Configure an In-App Automation or Scene trigger and audience*

In the Journey map:

1. Select the trigger card, then select the compose icon (
). If multiple triggers are configured, first select the trigger stack to expand it, and then select a trigger card, or you can select the plus icon () below the configured triggers. All methods open the configuration drawer.
1. Under **Triggers**, select and configure a [trigger](#triggers). Select **Add another** to add another trigger. Multiple triggers are handled as a boolean OR.
1. (Optional) Under **Display Conditions**, set [display conditions](#display-conditions) and [cancellation events](#cancellation-events).
1. (Optional) Under **Audience Conditions**, determine who can see your message:
   <table>
     <thead>
         <tr>
             <th>Option</th>
             <th>Description</th>
             <th>Steps</th>
         </tr>
     </thead>
     <tbody>
         <tr>
             <td><strong>All Users</strong></td>
             <td>Your entire app and/or web audience</td>
             <td>n/a</td>
         </tr>
         <tr>
             <td><strong>Target Specific Users</strong></td>
             <td>Audience members in a group you define</td>
             <td>See <a href="https://www.airship.com/docs/guides/audience/segmentation/target-specific-users/">Targeting Specific Users</a>.</td>
         </tr>
         <tr>
             <td><strong>Test Users</strong></td>
             <td>Members of a [Test Group](https://www.airship.com/docs/reference/glossary/#preview_test_groups)</td>
             <td>Select a Test Group.</td>
         </tr>
         <tr>
             <td><strong>Feature Flag Audience</strong></td>
             <td>Members of a [Feature Flag](https://www.airship.com/docs/reference/glossary/#feature_flag) Configuration audience<sup>1</sup></td>
             <td>Search for a flag by name, display name, or description, and then select a Configuration.</td>
         </tr>
     </tbody>
   </table>
   <p><sup>1. Configurations using the <a href="https://www.airship.com/docs/guides/experimentation/feature-flags/#conditions">Feature Flag access condition</a> are excluded.</sup></p>
1. Select **Save**.

> **Important:** You cannot edit the trigger configuration, cancellation events, or display conditions after the in-app experience is made active or while it is paused. You can edit the audience.
> 
> * To view the trigger configuration, cancellation events, and display conditions or to [set a tag](#set-a-tag) when the message is displayed, edit the in-app experience and go to the Behavior step.
> * To view or edit the audience configuration or set up a [Scene rollout](https://www.airship.com/docs/guides/features/messaging/scenes/rollouts/), edit the in-app experience and go to the Audience step.

## Triggers

All triggers are supported for both In-App Automations and Scenes except for Web URL, which is for Web Scenes only.

### App Open (Mobile App), Session Start (Web)

The *App Open (Mobile App), Session Start (Web) trigger* causes an In-App Automation or Scene to appear based on the number of times your audience opens your app or starts a web session.

Enter the number of times your audience must open your app or start a web session before the message will appear.

#### App Open behavior

A mobile app open is generated any time the mobile app changes from the background to the foreground, so message display timing varies depending on whether a user has opened the app before or currently has the app open. For a message with an App Open value of 1:

* **If a user has never opened the app before**, they will see the message the first time they open the app.
* **If a user has opened the app before and does not currently have the app open**, they will see the message the next time they open the app.
* **If a user currently has the app open**, the message will appear during the current session.

> **Tip:** If you are configuring a "Welcome" message intended to display when users first open your app:
> 
> * Set the App Open trigger value to 1.
> * Add the **New users** channel condition. See [Targeting specific users](https://www.airship.com/docs/guides/audience/segmentation/target-specific-users/).
> 
> If you want an onboarding message to appear the third time users open your app, set the App Open trigger value to 3.


#### Session Start behavior

A *web session* occurs when an end user directly visits a website with the Airship Web SDK present or by clicking or tapping a Web Push Notification that leads the visitor to the website. The page the user visits must have the Web SDK installed to track sessions. A new session is generated after 30 minutes of inactivity.

So, message display timing varies depending on whether a user visited the website in the past 30 minutes. A new session will not be generated within 30 minutes of when a previous session started. For a message with a Session Start value of 1:

* **If a user has never visited the website before**, they will see the message the first time they visit the website.
* **If a user visits the website and has visited the website in the past 30 minutes**, they will see the message the next time they visit the website.
* **If a user is currently viewing the website**, the message will appear during the next visit if it is 30 minutes after the current session started.

### App Update

The *App Update trigger* causes an In-App Automation or Scene to appear when your audience opens your app or starts a web session for the first time after an app or website update update.

Configuration steps:

1. Select **All app updates** or **Specific app updates**.
1. (For specific app updates) Set versions for each of your app's platforms.
    * Select **any version** or the operator you want to use to evaluate specific version numbers.
    * If you selected an operator, enter the version numbers you want to evaluate against. For Android apps, enter the `versionCode`. You can find your app's `versionCode` in your Google Play dashboard. For Web apps, [set an `appVersion` using the Web SDK](https://www.airship.com/docs/developer/sdk-integration/web/in-app-experiences/#app-version-updates).

> **Note:** The **Is between** operator includes boundary values. For example, entering versions 4.3 - 5.1 includes 4.3 and 5.1.


### Custom Event

The *Custom Event trigger* causes an In-App Automation or Scene to appear to your audience when Custom Events occur a specified number of times.

[Custom Events](https://www.airship.com/docs/reference/glossary/#custom_event) capture key events in your app or website, such as screen views, media views, stories read, button clicks, items purchased or added to cart.

> **Note:** [Server-side events](https://www.airship.com/docs/guides/audience/events/custom-events/#server-side-events) cannot be used to trigger an [In-App Automation](https://www.airship.com/docs/reference/glossary/#iaa) or [Scene](https://www.airship.com/docs/reference/glossary/#scene).
> 
> Custom Events used for In-App Automation or Scene triggers must be client-side events. Web Scenes can only use Custom Events tracked using the Web SDK. App Scenes and In-App Automations can only use Custom Events tracked using the Mobile SDK.

Configuration steps:

1. Search for an event. Results are limited to events that occurred in the last 30 days. If the event name you search for does not appear, select **Use [search term]** to use the event name as entered.
1. Enter the number of times the event must occur before the message will display.
1. (Optional) Select **Add Another** to add more Custom Events. Multiple events are handled as a boolean OR.

#### Filtering Custom Events {#filtering-custom-events}

When configuring the Custom Event trigger, you can filter Custom Events that are set on [Channel IDs](https://www.airship.com/docs/reference/glossary/#channel_dev), using numeric values associated with those Custom Events, or by key/value properties attached to the events. Filtering events this way can help you more precisely target your audience.

<p>For example, if you have a custom event named &ldquo;Purchase&rdquo;, with a purchase category <code>fedoras</code> and a value <code>125.0</code> representing the dollar amount of the purchase, you can add these criteria to the Purchase event so that your message is only seen by users spending at least $125 on fedoras.</p>
> **Note:** * Properties are only available for [custom events defined in your project](https://www.airship.com/docs/guides/audience/events/manage/).
> * Acceptable values and operators for event properties are based on configuration settings when adding the events to your project.
> * The filter **does not** show events and event properties for custom events associated with [Named Users](https://www.airship.com/docs/reference/glossary/#named_user). You can still use events associated with named users as triggers, but you must enter their information manually.

<ol>
<li>Select <strong>Add event properties</strong> for the custom event.</li>
<li>Select <strong>Add property</strong>, then <strong>Search for properties</strong> and search for a property, or select <strong>Add event value</strong>.</li>
<li>If applicable, select the operator you want to use to evaluate the value or property.</li>
<li>Enter or select the event or property value you want to filter for.</li>
<li>(Optional) Select the plus icon (
) to add an alternative for a filter.</li>
<li>(Optional) Select <strong>Add property</strong> or <strong>Add event value</strong> to add more filters.</li>
<li>Select <strong>All</strong> or <strong>ANY</strong> to determine how to evaluate multiple filters and alternatives within each filter.
<ul>
   <li>ALL = all criteria must be met (boolean AND)</li>
   <li>ANY = any criteria must be met (boolean OR)</li>
   </ul></li>
<li>Select <strong>Save</strong>.</li>
</ol>

### Feature Flag Interaction Event

The Feature Flag Interaction Event trigger initiates an In-App Automation or Scene when a [Feature Flag](https://www.airship.com/docs/reference/glossary/#feature_flag) interaction event occurs. The interaction event must be implemented for the app or website. See [Interaction events](https://www.airship.com/docs/guides/experimentation/feature-flags/#interaction-events) in the *Feature Flags* guide.

Configuration steps:

1. Search for a flag by name, display name, or description. If you also selected a Feature Flag Configuration as the message audience, that flag will be preselected for the trigger, but you can select a different one.

1. Select who can trigger the message display: 
   | Option | Description |
   | --- | --- |
   | **Users with feature access** | Trigger for members of a Feature Flag audience, which includes includes all Configuration audiences for a flag. When using the same flag for Audience and Trigger, you can only trigger for this group of users. |
| **Users without feature access** | Trigger for users who are not members of the Feature Flag audience. |

1. Enter the number of times the event must occur before the In-App Automation or Scene is triggered.

> **Important:** Before making your In-App Automation or Scene active, verify there are no scheduling conflicts between the message and Feature Flag Configuration:
> 
> 1. Go to the composer's Review step.
> 1. Under **Schedule**, compare the start and end settings for the Configuration and message.


### Screenview

The *Screenview trigger* causes an In-App Automation or Scene to appear when your audience views a screen a specified number of times. You must [configure app screens](https://www.airship.com/docs/guides/messaging/in-app-experiences/configuration/app-screens/) for mobile and web screen tracking in your project settings before you can select them as a trigger.

Configuration steps:

1. Select **Add a screen name**.
1. Search for the screen name.
1. (Optional) Select **Add another screen name** if you want to trigger for multiple screens. Multiple screens are handled as a boolean OR.
1. Enter the number of times your audience must view the screens before they will see your message.

### Web URL

The *Web URL trigger* initiates a Web Scene when your audience visits a web page that matches URL-based conditions. The Web SDK evaluates a URL when a browser page loads.

Use this trigger to display contextually relevant messaging based on user navigation, query parameters, and hashes without requiring web development resources. For use cases, see [Web URL targeting](https://www.airship.com/docs/guides/features/messaging/scenes/scenes/#web-url-targeting) in *Scenes*.

The Web channel must be selected for the Scene audience. Multiple conditions are handled as a boolean AND. To provide alternative URLs, configure an additional Web URL trigger. 

Configuration steps:

1. (Quickstart option) If you have a URL to target, paste it in the field for **Target URL**, then select **Generate conditions**. Airship will parse it into conditions for each part of the URL. Example target URL: `https://example.com/path/:name?param=value#my-anchor`.
1. Under **Conditions**, add or edit conditions by specifying a URL part, a value for the part, and an operator to determine how it is evaluated, such as "contains", "starts with", or "equals".<p>Configuration information for each URL part:
   <div class="table-scroll-wrapper">
   <table width="100%" class="reference-table">
   <col style="width:20%">
   <col style="width:40%">
   <col style="width:40%">
   <thead>
   <tr>
      <th>URL part</th>
      <th>Description</th>
      <th>Example value</th>
   </tr>
   </thead>
   <tbody>
   <tr>
      <td>Full URL</td>
      <td>A basic URL for your website</td>
      <td>https://www.example.com/products/reviews?utm_campaign=winter_clearance</td>
   </tr>
   <tr>
      <td>Domain</td>
      <td>The domain for your brand's website, with or without a subdomain</td>
      <td>example.com or sub.example.com</td>
   </tr>
   <tr>
      <td>Path</td>
      <td>A string, for matching static or dynamic URLs<p>
      <ul>
      <li>To include a tokenized value for matching dynamic URLs, use the format <code>/products/:id</code>. You must enter a value and select an operator for each token in the path.</li>
      <li>Only one condition can include tokens. For multiple tokens, include them in the same condition.</li>
      <li>To match any number of path sections at the start or end of a path, use the asterisk (*) wildcard character.</li>
      </ul>
      </td>
      <td><b>Static path value:</b> /products/reviews/<p><b>Dynamic path value with token:</b> /products/:id/reviews<br><b>Token value:</b> 1109<p>The above path and token values will match a URL containing <code>/products/1109/reviews</code>.<p><b>Wildcard:</b> /products*<p>The above path would match both <code>/products/1109/reviews</code> and <code>/products/reviews</code>.</td>
   </tr>
   <tr>
      <td>Hash</td>
      <td>An anchor to a location on a web page</td>
      <td>#my-anchor</td>
   </tr>
   <tr>
      <td>Query parameter</td>
      <td>A key/value pair in the format <code>param=value</code></td>
      <td>utm_campaign=winter_clearance</td>
   </tr>
   </tbody>
   </table>
   </div>
1. Select **Add condition** to enter more criteria.

We recommend testing each variation of the URLs defined in your conditions to verify they will successfully trigger a Scene. Under **Test a URL...**, enter a sample URL, select **Test trigger**, and view the success or failure response.

#### Example conditions configurations

The following are example conditions for various Web URL scenarios:

<div class="table-scroll-wrapper">
<table width="100%" class="reference-table">
  <col style="width:40%">
  <col style="width:60%">
<thead>
  <tr>
    <th>To display a Web Scene when a user...</th> 
    <th>Configure a condition with...</th>
  </tr>
</thead>
<tbody>
  <tr>
    <td>visits any product page</td>
    <td>
      <ul>
        <li>URL part: Path</li>
        <li>Operator: contains</li>
        <li>Value: <code>/products/</code></li>
      </ul>
    </td>
  </tr>
  <tr>
    <td>visits a campaign landing page</td>
    <td>
      <ul>
        <li>URL part: Full URL</li>
        <li>Operator: starts with</li>
        <li>Value: <code>https://example.com/spring_sale/</code></li>
      </ul>
    </td>
  </tr>
  <tr>
    <td>completes a purchase</td>
    <td>
      <ul>
        <li>URL part: Path</li>
        <li>Operator: equals</li>
        <li>Value: <code>/cart/:cart_id/checkout/complete</code></li>
      </ul><br>With<p>
      <ul>
        <li>Token name: cart_id</li>
        <li>Operator: is anything</li>
      </ul>
    </td>
  </tr>
</tbody>
</table>
</div>

#### Using URLs in personalization

Web URL trigger components can be used to personalize messages with [Handlebars](https://www.airship.com/docs/reference/glossary/#handlebars). When a Web Scene is triggered with a URL, the following properties are available:

| Component | Description |
| --- | --- |
| **`{{url.protocol}}`** | The protocol — For example, `http` or `https` |
| **`{{url.domain}}`** | The domain — For example, `example.com` |
| **`{{url.path}}`** | The full path — For example, `/products/123` |
| **`{{url.path_groups}}`** | The named tokens defined in the trigger — For example, `/products/:id` would yield `{{url.path_groups.id}}`. |
| **`{{url.search_params}}`** | The parsed query string of the page — For example, `?utm_source=airship` would yield `{{url.search_params.utm_source.0}}`. _Note: Search parameter values are arrays of strings. If your search parameter contains a single string value, access it using index 0._ |
| **`{{url.hash}}`** | The anchor portion of the URL — For example, `#my-anchor-tag` |

## Trigger Options

Configure additional behaviors for your In-App Automation or Scene.

### Cancellation Events

Cancellation events prevent the message from appearing if a specified Custom Event occurs. You must also specify at least one [display condition](#display-conditions).

Configuration steps:

1. Enable **Cancellation Events**. In the [Journey Map](https://www.airship.com/docs/reference/glossary/#journey_map), you must set a display condition before you can enable Cancellation Events.
1. Complete the same workflow used for the [Custom Event trigger](#custom-event) and optional [filtering](#filtering-custom-events).

### Set a Tag

The ability to set a tag when the message displays is key to promoting new features. The suggested approach is to display messages regarding a feature if the tag does not exist, and to then set the tag to record either the fact that the user has acknowledged the message, or to record actual usage of the feature.

* If you are using [localized content for in-app-automation](https://www.airship.com/docs/guides/messaging/in-app-experiences/in-app-automation/localization/), this setting is instead in the Actions step. For Scenes, this setting is instead available per screen in the Content step.
* This setting is not available when configuring triggers in the Journey map.

Configuration steps:

1. Enable **Set a tag**.
1. Search for tags that exist in the system or create a new tag.

## Display Conditions

Display conditions determine whether or not your message displays after a trigger event occurs. The message does not display until your conditions are met.

In the composers, if you set a [cancellation event](#cancellation-events), you must also set at least one display condition. In the [Journey Map](https://www.airship.com/docs/reference/glossary/#journey_map), you cannot enable **Cancellation Events** until you set a display condition.

### Time Has Elapsed

Set how much time must elapse after receiving the triggering event before your message is eligible for display, up to 24 hours.

Configuration steps:

1. Enable **Time has elapsed**.
1. Enter an amount of time in seconds, minutes, or hours.

### Viewing a Specific App Screen {#screenview-condition}

Limit message display to when a trigger occurs while your audience is viewing a specific app screen. You must first [configure app screens](https://www.airship.com/docs/guides/messaging/in-app-experiences/configuration/app-screens/) for mobile and web screen tracking in your project settings before you can select them as a condition.

Configuration steps:

1. Enable **Viewing a specific app screen**.
1. Select **Add a screen name** and search for a screen name.
1. (Optional) Select **Add another screen name** to add additional screens. Multiple screens are handled as a boolean OR.