I am currently in the process of implementing behavioural triggers content block. I have a scenario in which the default product link from product catalog refers to a certain region that will not apply to all subscribers receiving the personalised content. An example of the default link is: http://www.example.com/eu/en-nl/product-detail-page. The slug /eu/en-nl/ needs to be customised according to subscribers data.

I had a chat with marketing cloud support and unfortunately, it is not possible to customise the ProductLink directly from the interface. But, it is theoretically possible to customise the javascript element, visible from the code view.

I had the assumption that I could simply retrieve the product link from this javascript block and then use the replace() function to replace the slug with a custom slug. But after further investigation, I could see that the product link was not the same as in the product catalog. It is a system generated link in which the redirect url is not directly visible (example: {{MC-MID}}.collect.igodigital.com/{{some_sort_of_hashed_product_link}}.

I performed an api request to this link, and I could see that the response headers included 'location', which was the redirect url.

Therefore my initial question:

Does anyone know how to read the response headers from HTTP.Get function of server side javascript?

The following code:

var response = HTTP.Get(url);

Returns null unfortunately

Answer to initial question:

I used the Script.Util.HttpRequest function, which allows you to retrieve the response header.

<script runat=server>
  var req = new Script.Util.HttpRequest("http://www.myurl.com/");
  req.method = "GET";

  var resp = req.send();

  Platform.Response.Write("Content:<br/ >"+resp.content +"");
  Platform.Response.Write("Return header: "+resp.headers["location"] +"");

Unfortunately, I received the following error:

{"message":"Use of Common Language Runtime (CLR) is not allowed","description":"System.Security.SecurityException: Use of Common Language Runtime (CLR) is not allowed - from Jint\r\n\r\n"}

Marketing cloud support told me that

The CLR decline some requests to maintain the quality of the data.

So the idea of performing a GET request to the system generated link will not work in this case.

I had to implement another solution.

Current solution

Currently I am conducting a lookup to the productLink column in the data extension containing the product catalog using the product_sku provided by the javascript block of personalization builder. I then execute the replace() function:

var region = Platform.Variable.GetValue("@cartRegionSlug");
var country = Platform.Variable.GetValue("@country");
var language = Platform.Variable.GetValue("@languageLowerCase");
var slug = "/" + region + "/" + language + "-" + country + "/"
//lookup url in product catalog with sku id
var productLink = Platform.Function.Lookup('Catalog_feed_for_export', 'ProductLink', 'SkuID', product.sku_id)
var adjustedProductLink = productLink.replace('/uk/en-gb/', slug)
// swap product.link for custom link
product.link = adjustedProductLink;

This seems to work fine. But I don't feel fine using this solution, as the original redirect generated by personalization builder is ignored.

Any thoughts on this?


You should investigate localization of some of the attributes in your Product Catalog. What you're trying to do is easily achievable with some standard functionality in PI (or whatevever they're calling it at your time of reading).

Redefine your product catalog to incorporate localized fields for any of the fields that vary according to the geography. In your example, you're wanting to localize "ProductLink". Add a field for "locale_en-nl_ProductLink" and use the market-specific URL in your catalog for the product. You can do the same for RegularPrice, SalePrice etc.

When requesting localized email or web recommendations, add the parameter "?locale=en-nl" to the URL to get recommendations and, voila! - links, prices, images in French, Dutch, German etc. The same functionality applies to Behavioural Trigger data - add something analogous to this line of AMPScript somewhere above the Behavioural Trigger Content block (the variable name "@event_locale" is important)...

SET @event_locale = "en-NL"

If you do own a passport and all your customers aren't from Indianapolis, you'll need to hack the mixture of SSJS and hard-coded HTML generated by the Content Builder SDK Block the US-centric developers put together to insert your Yen, Euro, Pound symbols and, again, you can use a localized field in your Catalog for that, "locale_jp-JP_CurrencySymbol", "locale_en-GB_CurrencySymbol" or whatever.

  • 2
    for different currencies, I would recommend not using the RegularPrice field but a localized custom field like RegularPriceDisplay and the same locale fields for each currency as needed, You can then use this in your BT content block
    – EazyE
    Sep 16 '20 at 19:33
  • @EazyE That'd work, too, for sure.
    – Macca
    Sep 17 '20 at 1:19

Create locale Productlinks in your catalog like you would do with other fields where you want to store locale based values.

example: locale_de-DE_ProductLink|locale_en-GB_ProductLink|locale_it-IT_ProductLink|locale_pl-PL_ProductLink ...

Then perform a httpget to this web recommendation probably (This uses super messages). Then perform a search operation to receive the right localized productlink and display/integrate it or whatever.

Is this a solution? I dont know ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.