How to deploy recommendation with SFMC
To deploy a recommendation with SFMC, you need to configure the tool first. If you have already done so, you can move on to the next step. https://app.gitbook.com/o/iFKI1JaxSfPoiGt4tT2k/s/6Yw9IRJ6KbbucQPwZUCZ/~/changes/368/recommendations-and-merchandising-1/how-tos/how-to-configure-your-email-integration/how-to-configure-sfmc-integration
Select or Create a Recommendation Template
You need to associate a recommendation template.
If no suitable template exists, you can create a new one in the Templates section.

If the interface shows the message “Template functionality is not enabled”, please contact the AB Tasty team to enable template access.

Add the Code Snippet in SFMC
Click on Get integration snippet button
Copy-paste the AMPscript snippet example below into your SFMC email:
%%[
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.


Snippet structure
Below is a more complete example of the AMPscript code snippet
%%[
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.
%%[
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.
<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:
%%=TreatAsContent(@response)=%%Last updated
Was this helpful?


