Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 1-click unsubscribe docs #800

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions content/preferences/commercial-unsubscribe.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: "Commercial Unsubscribe"
description: "Learn how to manage commercial email unsubscribe functionality in Knock"
tags: ["preferences", "unsubscribe", "commercial", "broadcasts", "workflows"]
section: Preferences
---

Knock provides built-in support for commercial email unsubscribe functionality, allowing recipients to opt out of promotional or commercial messages with a single click.

## How commercial unsubscribe works

When you mark a workflow or broadcast as commercial, Knock automatically handles the necessary unsubscribe functionality:

1. Adds required unsubscribe headers to all emails sent through that workflow or broadcast
1. Provides an unsubscribe URL variable that can be included in your email templates
1. Manages recipient opt-outs during preference set evaluation

## Configuring commercial workflows

To enable commercial unsubscribe functionality for a workflow or broadcast:

1. Navigate to the workflow or broadcast
1. For a workflow, click "Manage workflow". For a broadcast, click "Edit details".
1. Toggle "Commercial"
1. Save your changes

Once enabled, Knock will automatically include the necessary unsubscribe headers in all emails sent through that workflow.

## Adding unsubscribe links to emails

### Using footer links

When configuring an email layout using the visual editor, you can toggle the "Include commercial unsubscribe link" input to include the unsubscribe link.

### Using the code editor

You can add an unsubscribe link to your email layouts or templates using the built-in variable:

```liquid title="Show unsubscribe link"
<a href="{{vars.commercial_unsubscribe_url}}">Unsubscribe</a>
```

You can conditionally include the link by checking if the variable is present:

```liquid title="Show unsubscribe link only for commercial messages"
{% if vars.commercial_unsubscribe_url %}
<a href="{{vars.commercial_unsubscribe_url}}">Unsubscribe</a>
{% endif %}
```

## Configuring the confirmation page

When a user unsubscribes by directly clicking the unsubscribe link in a message, Knock will display a confirmation page indicating they have been succesfully unsubscribed from commercial messages. You can customize this page by navigating to "Developers" > "Preferences", then clicking the "Unsubscribe" tab.

### Standard confirmation page

You can customize the title and body text that will appear on the Knock confirmation page.

### Custom redirect URL

You can provide a URL that recipient's should be redirected to after unsubscribing.

## Preference evaluation rules

When a recipient clicks the unsubscribe link, their default preference set will be updated, marking `commercial_unsubscribe` as true. They will be opted-out of commercial messages, and they will continue to receive transactional messages based on their other preferences.

## Learn more

To learn more about managing recipient preferences and building preference centers with Knock, visit our [preferences overview](/preferences/overview).
4 changes: 4 additions & 0 deletions content/preferences/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ When Knock runs a workflow for a user, we evaluate their `PreferenceSet`. A mess

A preference set is built using three keys: `categories`, `channel_types`, `workflows`. These keys resolve to boolean values to determine if a user has opted out of receiving a notification.

The default preference set also has the `commercial_unsubscribe` which determines if the recipient should receive notifications sent by commercial workflows or broadcasts.

A few examples:

```json title="Unsubscribe user from admin category notifications"
Expand Down Expand Up @@ -241,6 +243,7 @@ When a workflow is triggered, Knock will evaluate the preferences for each `reci

</Accordion>
</AccordionGroup>

## Bulk set user preferences

You can update the preferences of up to 1000 users in a single batch by using the `users.bulkSetPreferences` method. This executes an asynchronous job which will overwrite any existing preferences for the users provided. You can track the progress of the `BulkOperation` returned via the [bulk operation API](/reference#bulk-operations).
Expand All @@ -258,3 +261,4 @@ You can update the preferences of up to 1000 users in a single batch by using th
- [Object preferences](/preferences/object-preferences). In the guide above, we referred to user preferences. You can also set preferences for objects.
- [Preference conditions](/preferences/preference-conditions). You can build advanced conditions and store them on Knock’s preference model to power use cases such as per-resource muting (example: mute notifications about this task) or threshold alerts (example: only notify me if my account balance is below $5).
- Workflow overrides. If you need to override a recipient's notification preferences to send notifications like a password reset email, you can override the preferences model. To do this, go to your workflow, click "Manage workflow," and enable "Override recipient preferences." You will need to commit this change for it to take effect. When enabled, the workflow will send to all of its channels, regardless of the recipient's preferences.
- [Commercial unsubscribe](/preferences/commercial-unsubscribe). You can configure 1-click unsubscribe links to help users opt-out of commercial or promotional notifications and comply with CAN-SPAM requirements.
5 changes: 5 additions & 0 deletions data/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ const sidebarContent: SidebarSection[] = [
{ slug: "/tenant-preferences", title: "Tenant preferences" },
{ slug: "/object-preferences", title: "Object preferences" },
{ slug: "/preference-conditions", title: "Preferences conditions" },
{
slug: "/commercial-unsubscribe",
title: "Commercial unsubscribe",
isBeta: true,
},
],
},
{
Expand Down
Loading