> For the complete documentation index, see [llms.txt](https://docs.abtasty.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.abtasty.com/~/revisions/4h93YjMk2bPutMvfaOT0/recommendations-and-merchandising-1/how-tos/how-to-configure-your-email-integration/how-to-configure-sfmc-integration.md).

# How to configure SFMC integration

This how-to explains how to insert a block of **dynamic product recommendations** into an SFMC (Salesforce Marketing Cloud) email by calling the Reco & Merch API from AB Tasty. This enables showing personalized products in real time, at the moment the email is opened.

{% hint style="info" %}
**Note**: The SFMC integration is done via **API**. There is currently no dedicated cartridge available.
{% endhint %}

### Prerequisites

* Access to **Content Builder** in SFMC.
* A **Reco & Merch template** already configured on AB Tasty.
* A valid **Bearer Token** provided by AB Tasty.
* Required variables available in your **Data Extension** (e.g. `EmailAddr`, `CodeEAN`).

{% stepper %}
{% step %}

### Connect SFMC to Reco & Merch

1. Go to **Settings > Integrations** in your AB Tasty Reco & Merch interface.
2. Click **Connect SFMC**.
3. A pop-up window will open to authenticate your SFMC account.
4. Once the connection is successful, your workspace will be linked to SFMC.

<figure><img src="/files/QJlAtmgScegkJZhy6FES" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/WkZFuSKkXJgDgvBsQljx" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Select or Create a Recommendation Template

1. After connecting, you need to associate a **recommendation template**.
2. If no suitable template exists, you can create a new one in the **Templates** section.

<figure><img src="/files/2uKJo3CGiLYmtEMPoXXr" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Deploy the Recommendation

When your template is ready:

1. Go to the **Deploy Recommendation** section.
2. Select the option **On your emailing platform**.
3. A unique identifier (API URL) will be generated. This identifier is automatically updated whenever you make changes to the template.

{% hint style="danger" %}
If the interface shows the message *“Template functionality is not enabled”*, please contact the AB Tasty team to enable template access.

![](/files/xBcXg3krKAPTNg91s71k)
{% endhint %}
{% endstep %}

{% step %}

### Add the Code Snippet in SFMC

Copy-paste the AMPscript snippet example below into your SFMC email:&#x20;

```
%%[
set @url = "https://uc-info.eu.abtasty.com/v1/reco/1010/template/3d815596-8f6e-4ed4-a373-89792a9a2e06/recos/366c16d0-4934-4f31-930e-a57a1e3f757c"

  Platform.Load("Core","1.1.1");
  var url = Variable.GetValue("@url");
  var headerNames   = ["Authorization"];
  var headerValues  = ["Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaXRlX2lkIjoxMDEwLCJpYXQiOjE3NDI0NzYzNzIsImp0aSI6IlhDczN3WVdXM0dIVHlRNmx0VXY1TTkzR2hXdDlDZGkyR3lhQnJwUEdacE0ifQ.n3OUVQJyyHUXR2zene-OA7VVb4hUJOnVlGQqfmc6tuw"];
  var response      = HTTP.Get(url, headerNames, headerValues);
  Variable.SetValue("@response", response.Content);
%%=TreatAsContent(@response)=%%
]%%
```

* **@url**: corresponds to the endpoint generated for your recommendation template.
* **Authorization**: insert the **Bearer token** provided by AB Tasty.
* The **@response** variable will store the dynamic recommendation and inject it into your email.

<figure><img src="/files/JZqIsP1Ld1zus807LAkR" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/zmewoa6ILjzvGEi0i7s1" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### Snippet structure

Below is a more complete example of the AMPscript code snippet

```ampscript
%%[
var @CodeEAN, @url
set @CodeEAN = [CodeEAN]
set @url = Concat(
  "https://uc-info.eu.abtasty.com/v1/reco/889/template/<TEMPLATE_ID>/recos/<RECO_ID>",
  "?variables=%7B%22bought_item%22:%22", @CodeEAN, "%22%7D"
)
]%%

<script runat="server">
  Platform.Load("Core","1.1.1");
  var url = Variable.GetValue("@url");
  var headerNames = ["Authorization"];
  var headerValues = ["Bearer <YOUR_BEARER_TOKEN>"];
  var response = HTTP.Get(url, headerNames, headerValues);
  Variable.SetValue("@response", response.Content);
</script>

%%=TreatAsContent(@response)=%%
```

This code execute the 3 steps below :

#### Step 1:  Build the URL with AMPScript

Use AMPScript (`%%[ ... ]%%`) to prepare the API request URL with dynamic variables from the Data Extension.

```ampscript
%%[
var @CodeEAN, @url

/* Retrieve CodeEAN from the Data Extension */
set @CodeEAN = [CodeEAN]

/* Build the final API URL */
set @url = Concat(
  "https://uc-info.eu.abtasty.com/v1/reco/889/template/<TEMPLATE_ID>/recos/<RECO_ID>",
  "?variables=%7B%22bought_item%22:%22", @CodeEAN, "%22%7D"
)
]%%
```

#### Step 2: Call the API with SSJS

Use **Server-Side JavaScript (SSJS)** inside `<script runat="server">...</script>` to execute the HTTP request.

```javascript
<script runat="server">
  Platform.Load("Core","1.1.1");
  var url = Variable.GetValue("@url");
  var headerNames = ["Authorization"];
  var headerValues = ["Bearer <YOUR_BEARER_TOKEN>"];
  var response = HTTP.Get(url, headerNames, headerValues);
  Variable.SetValue("@response", response.Content);
</script>
```

#### Step 3: 1Inject the API Response into the Email

Display the API’s HTML/JSON response directly in the body of the email:

<pre class="language-ampscript"><code class="lang-ampscript"><strong>%%=TreatAsContent(@response)=%%
</strong></code></pre>

### Notes on SFMC&#x20;

Below are some notes on SFMC

**Performance**

* Every email open triggers a live API call.
* High-volume sends (500k+ subscribers) = high API traffic.
* Ensure AB Tasty API quota is sufficient.

**Fallback**

* If the API fails, the block may be empty.
* Always define a static fallback (e.g. “Top Sellers” block).

**Security**

* The **Bearer Token** is sensitive.
* Rotate it regularly and avoid exposing it in shared snippets.
* For extra safety, use a proxy to hide the token.

**Data Extension alignment**

* Verify all fields (`CodeEAN`, `EmailAddr`) exist for every subscriber.
* If missing, the API call URL will be invalid → “400 Bad Request” errors.

**Rendering**

* Always test in **Preview & Test** with real subscriber profiles.
* Validate rendering across multiple email clients (Gmail, Outlook, Mobile).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.abtasty.com/~/revisions/4h93YjMk2bPutMvfaOT0/recommendations-and-merchandising-1/how-tos/how-to-configure-your-email-integration/how-to-configure-sfmc-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
