Fetching coupons in Emarsys
In this tutorial, let's set up Emarsys to retrieve existing coupons from Talon.One and use them in an Emarsys campaign.
To do so, we rely on the Emarsys-specific Get coupon endpoint.
Talon.One requirements
- You have set up an Application.
- Your Application contains a running campaign with the Coupons feature enabled.
- You have added coupons to the campaign.
The Emarsys-specific endpoint supports only personal codes at the moment.
You can edit the default format of the coupon codes in the campaign's Settings section.
Emarsys requirements
- You have set up your Emarsys account.
- You have an active Emarsys campaign for which you want to use coupon codes.
In this tutorial, we'll use a block-based email campaign.
Creating an API key in Talon.One
In the Campaign Manager, create an Emarsys-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 Emarsys.
-
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.
Creating a connection in Emarsys
To retrieve a coupon code from Talon.One, we call the following endpoint:
https://integration.talon.one/emarsys/customer_profiles/coupons
See API Docs
To access this endpoint, create an External Content connection in Emarsys:
- Sign in to your Emarsys account.
- Open Content > External Content.
- Click Create Connection.
- In Connection, enter the following details:
- Name: A descriptive name for the connection.
- API URL:
https://integration.talon.one/emarsys/customer_profiles/coupons?deployment=YOUR_DEPLOYMENT_URL
, whereYOUR_DEPLOYMENT_URL
is the base URL of your Talon.One deployment.
- In Authentication, enter the following details:
- Method: HTTP basic authentication
- User name:
ApiKey-v1
- Password: The Emarsys-specific API key you created.
- In Fields, enter the following details:
-
Reference Fields:
Field name Value for testing integrationId
A valid Talon.One customer integration ID. Example: URNGV8294NV
.campaignId
The ID of the Talon.One campaign containing the coupons. Example: 34
. -
Response Fields: The Talon.One coupon attributes to retrieve.
For example, add avalue
response field to retrieve the coupon code. You can also use custom attributes.
noteFor a list of supported attributes, see the
coupons
array of the List customer data response. -
- To test the connection with the values provided, click Test.
- If the test is successful, click Save.
Using custom coupon attributes
You can use custom attributes as response fields. Ensure that the custom attribute has its Entity set to Coupon.
For example, you can create a custom attribute named percentage_discount
, use it for
your coupons, and include the attribute in the response from Talon.One.
Creating tokens in Emarsys
To use a coupon attribute in your Emarsys campaign, create a Personalization token:
- In Emarsys, open Content > Personalization.
- Click Create Token and choose External Content.
- In Setup, enter the following details:
- Name: A descriptive name for the token.
- (Optional) Category: Create or assign a category. This helps you organize your tokens. The categories are shown in the Personalization sidebar when editing your campaign.
- External Content preset: Create or assign a preset.
- Field: The coupon attribute to use in your Emarsys campaign. For example, to use the coupon code in your campaign, select
value
.
- Click Save.
Repeat the above steps for every coupon attribute you want to use in your Emarsys campaign.
Creating an External Content preset
To manage recurring coupon requests to Talon.One, create an External Content preset and assign it to your Personalization token. See the Emarsys docs.
Assume you want to retrieve coupons of a specific campaign in Talon.One. The ID of this campaign is 34
.
Also, you want to use the customer's email address as the unique identifier to retrieve coupon codes from Talon.One.
In this case, create the following preset and assign it to your token:
-
Name: A descriptive name for the preset.
-
Connection: The External Content connection you created.
-
Parameters:
Name Type Value integrationId
Contact Field Email
campaignId
Constant 34
Using coupons in an Emarsys campaign
Now that we've established a connection and created a token, we can use the token in a campaign:
- Open your Emarsys campaign for editing.
In this tutorial, we'll use a block-based email campaign. - Go to the Content Creation step of the campaign creation wizard.
- In the editor sidebar, open Personalization and find your created tokens in the Custom Tokens section.
- Drag the desired tokens into the content editor window.
- To test your coupon attributes, use the Testmail feature.
- Click Finish Editing.
When using the Inbox Preview feature, placeholders are displayed instead of the actual token values.