Creating email alerts with Mode and email filters
Folks often want to set up Mode schedules so that they only get emails about the report when it returns certain results. While this isn't possible natively in Mode today, you can easily set up alerts like this using email filters. The example below shows how to do it in Gmail, though you could set up the same filters in most other email clients.
Step 1: Add a flag to your Mode report when you want it to trigger your alert
Suppose you've got a report that counts how many people are abandoning their shopping cart right before checking out. You should first add logic to your query so that if you want to be alerted, it adds a distinctive value to your query result.
For example, you could do something like this:
## Report: Shopping Cart Abandonment Report SELECT abandonment_rate, CASE WHEN abandonment_rate > 0.1 THEN 'SHOPPING CART ALERT DANGER DANGER' ELSE 'shopping cart performing normally' END AS alert FROM cart_abandonments
This alert value should be unique because it's what you'll use filter alerts in your email. Unless “SHOPPING CART ALERT DANGER DANGER” frequently appears in your emails, this example should work.
Step 2: Set up a subscription in Mode that will email you this report
Set up a scheduled share (https://help.modeanalytics.com/articles/share-via-email/) in Mode to send this report to your email address. Make sure to include the embedded data table. The table will be used to identify the alert.
Step 3: Set up automatic email filters
Next, set up a filter in your email client that automatically deletes emails of this Mode report if they don't have the exact text in Step 1. When the report runs and the alert isn't triggered, the text won't be included in the data table in your email and the filter will delete the email. If the alert is triggered, the text will be included, so the filter will let it through and the email will show up in your inbox just like any other.
To do this in Gmail, click on the arrow in the far right of the search bar at the top of your inbox. From here, create a filter that filters out
- emails from email@example.com
- that contain the text in the title of your report
- and doesn't contain the alert text from step 1.
This filter will delete emails from this report that don't have the alert value, including results that return no rows.
The picture below shows how to do this in Gmail:
Next, click the “Create filter with this search” link at the bottom of the form. On the next form, choose “Skip the Inbox (Archive it),” “Mark as read,” “Delete it.”
Fowarding it to a list
Most email clients also allow you to set up filters that automatically forward emails as well. You can use the same process above to automatically forward emails to other emails or email lists.