Skip to content

Braze Actions Deeplinks

Braze Actions let you use “deeplinks” to perform native SDK functionality.

The Braze dashboard includes several standard on-click actions (Request Push Permission, Log Custom Event, and Log Custom Attribute) which can be used in in-app messages and Content Cards.

For all other actions, or to combine multiple actions, use this guide to construct your own Braze Action deeplink.

SDK Support

The brazeActions:// deeplink scheme can be used wherever a deeplink or redirect option exists within in-app messages and Content Cards.

For HTML in-app messages, use the Javascript Bridge instead, as deeplinks are not supported in HTML message types.

Schema

You can include multiple action steps within a container action type. A single step without a container is also valid.

1
2
3
4
{
    "type": "container",
    "steps": []
}

An individual step contains an action type and optional args array:

1
2
3
4
{
    "type": "logCustomEvent",
    "args": ["event name", {"event": ["properties"]}]
}

URI

The Braze Actions URI scheme is brazeActions://v1/{base64encodedJsonString}.

The following JavaScript shows how to encode and decode the JSON string:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function decode(encoded) {
    const binary = window.atob(encoded.replace(/-/g, '+').replace(/_/g, '/'));
    let bits8 = new Uint8Array(binary.length);
    for (let i = 0; i < binary.length; i++) {
      bits8[i] = binary.charCodeAt(i);
    }
    const bits16 = new Uint16Array(bits8.buffer);
    return String.fromCharCode(...bits16);
}

/**
 * Returns a url-safe base64 encoded string of the input.
 * Unicode inputs are accepted.
 * Converts a UTF-16 string to UTF-8 to comply with base64 encoding limitations.
 */
function encode(input) {
    // Split the original 16-bit char code into two 8-bit char codes then 
    // reconstitute a new string (of double length) using those 8-bit codes
    // into a UTF-8 string.
    const codeUnits = new Uint16Array(input.length);
    for (let i = 0; i < codeUnits.length; i++) {
        codeUnits[i] = input.charCodeAt(i);
    }
    const charCodes = new Uint8Array(codeUnits.buffer);
    let utf8String = "";
    for (let i = 0; i < charCodes.byteLength; i++) {
        utf8String += String.fromCharCode(charCodes[i]);
    }
    return btoa(utf8String).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
}

Supported Actions

Type Args
container An array of other actions to perform
logCustomEvent 1. event name
2. event properties JSON object (optional)
setEmailNotificationSubscriptionType "opted_in" | "subscribed" | "unsubscribed"
setPushNotificationSubscriptionType "opted_in" | "subscribed" | "unsubscribed"
setCustomUserAttribute 1. attribute_name
2. attribute_value
requestPushPermission N/A
openLink 1. url
2. openInNewTab (boolean)
openLinkInWebview url
addToSubscriptionGroup subscriptionGroupId
removeFromSubscriptionGroup subscriptionGroupId
addToCustomAttributeArray 1. attribute_name
2. attribute_value
removeFromCustomAttributeArray 1. attribute_name
2. attribute_value

JSON Encoder

Enter a JSON string to see the resulting brazeActions:// URI. Or, enter a brazeActions:// URI to decode its JSON.

JSON Input

Deeplink Output

New Stuff!