Triggering Merchandising Campaigns Dynamically

Campaigns can be triggered on the API directly and in Clerk.js embedcodes

Merchandising Campaigns are handled from my.clerk.io -> Merchandising.

The Campaigns use Triggers to decide where it should be used, like on a specific search or when viewing certain products.

However, Campaigns can also be triggered directly from the API or any Clerk.io embedcode.

1. Start by creating a Campaign with no Triggers, and note the ID of the campaign from the URL:

2. Now you can trigger this campaign in an API call by adding the argument

merchandising=[“INSERT_CAMPAIGN_ID”]

$ curl -X POST \
       -H 'Content-Type: application/json' \
       -d '{"key":      "your_api_key",
            "visitor":  "aR9Km32l",
            "limit":    4,
            "labels":   ["Most Popylar"],
            "merchandising": ["boost-bracelets"]' \
       http://api.clerk.io/v2/recommendations/popular

3. They can also be triggered in Clerk.js embedcodes:

<span class="clerk"
  data-template="@home-page-popular"
  data-merchandising=["boost-bracelets"]
></span>

Using this method, you can create logics in the frontend for when you want to apply a Campaign.

Tip: If you want to apply multiple Merchandising campaigns to the same code, you can add several ID’s to the list:

$ curl -X POST \
       -H 'Content-Type: application/json' \
       -d '{"key":      "your_api_key",
            "visitor":  "aR9Km32l",
            "limit":    4,
            "labels":   ["Most Popylar"],
            "merchandising": ["boost-bracelets", "high-margin", "whitelabel"]' \
       http://api.clerk.io/v2/recommendations/popular
<span class="clerk"
  data-template="@home-page-popular"
  data-merchandising=["boost-bracelets", "high-margin", "whitelabel"]
></span>