Creating a birthday promotion via Braze
Birthdays are a great opportunity to give presents to someone so treating your customers with a discount on their birthday is a great way to increase brand loyalty. In this tutorial, let's see how to build a birthday promotion using Braze and Talon.One.
Let's imagine that we want to email a customer on their birthday via Braze. This email contains a coupon for the customer. The coupon's validity starts on the day the email is sent to the customer and ends seven days after that date.
When the customer redeems the coupon within its validity period, they get 10% off on their whole order.
Talon.One requirements
- You are an Admin user.
- You have set up an Application.
- Your Application contains a running campaign with the Coupons feature enabled.
You can edit the default format of the coupon codes in the campaign's Settings section.
Braze requirements
- You have created a campaign or canvas in Braze.
- The campaign is configured so that it sends an email to customers on their birthday. For more information, see Creating an email campaign.
- You have a way to identify a given customer across Talon.One and Braze.
In this tutorial, we assume a customer's Talon.One
integrationId
is always equal to Braze'suser_id
. You can also create a new property on your Braze customer profiles to store Talon.One's integration ID.
Creating an API key in Talon.One
In the Campaign Manager, create a Braze-specific API key:
-
In your Application, click Settings > Integration API Keys.
-
Click Create API Key.
-
In the Create API Key drawer, select Production as the key type.
-
In Key name, type a name to identify the key.
-
In Key expiration date, select a date.
-
In Third-party integration, select Yes.
-
From Platform, select Braze.
-
Click Create API Key.
-
Click to copy the key for use.
noteYou cannot view or copy the API key after closing the drawer. If you lose it, create another API key.
We will use the API key in the Braze campaign template.
Creating the birthday coupon code
To generate a coupon from Braze, we call the following endpoint:
https://integration.talon.one/braze/coupon
See API Docs
To trigger the endpoint, we must use Braze's Connected Content feature.
We assume that your customer profile in Braze contains a unique identifier that is equal to the customer integration ID in Talon.One.
In this tutorial, we use ${user_id}
. Ensure the user ID matches the integration ID in Talon.One.
-
Open your Braze email campaign for editing.
-
Add the following Connected Content call to the email body, where:
YOUR_DEPLOYMENT_URL
is the base URL of your Talon.One deployment.YOUR_APPLICATION_ID
is the ID of your Application in Talon.One.YOUR_CAMPAIGN_ID
is the ID of your campaign in Talon.One.YOUR_API_KEY
is the API key you created.
{% assign today = 'now' | date: "%Y-%m-%dT%H:%M:%SZ" %}
{% assign todayinseconds = 'now' | date: "%s" %}
{% assign seven_days = {{todayinseconds}} | plus: 604800 | date: "%Y-%m-%dT%H:%M:%SZ" %}
{% capture postbody %}
{"deploymentUrl": "YOUR_DEPLOYMENT_URL", "applicationId":YOUR_APPLICATION_ID, "campaignId":YOUR_CAMPAIGN_ID, "identifier":"{{ 'now' | date: '%Y-%m-%d %H:%M:%S.%N' }}", "integrationId":"{{${user_id}}}", "startDate":"{{today}}", "expiryDate":"{{seven_days}}"}
{% endcapture %}
{% connected_content https://integration.talon.one/braze/coupon
:headers {
"Authorization": "ApiKey-v1 YOUR_API_KEY"
}
:method post
:body {{postbody}}
:content_type application/json
:save result
%}
<p>Your coupon code is: {{result.Value}}</p>note- In the example above, we use a timestamp for the
identifier
parameter. This ensures that a new coupon code is generated for each email during testing. In production, consider using one of the available personalization tags, for example, the dispatch ID. result.Value
must be written with a capitalV
, according to the response of the Create coupon endpoint.
-
To test your request:
- In the sidebar, click Preview & Test.
- In Preview message as user, select Search User and search for an existing user in Braze.
You should see a coupon code.
Your birthday coupon codes are now generated automatically when your campaign is running. The coupon start date is set as the time Braze sent the email. The coupon end date is the time Braze sent the email + seven days.