Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Link to a specific basket

Shows how to set up abandoned basket trigger campaigns to link to a particular basket with the abandoned products.

📘

Note

In Optimizely Customized Commerce, a basket _is also known as a _shopping cart.

Consider the following main areas:

  • Changes to basket page tracking.
  • Steps for the Email Service Provider (ESP).
  • Populating the basket with abandoned products.

Basket page tracking

To restore a basket for a session, you need to pass a basketId value in the Optimizely tracking variable. The basketId should be unique for a user’s session on your site and must relate back to a basket state stored on the your side.

To extend the basket page tracking to track the basketId, include a string value in the tracking variable. For example:

{   
      "type"          : "basket",
      "ip"            : "10.42.37.139",
      "session"       : "123456789012|a1b2c3d4e5A6B7C8D9E0f1g2h3i4j5F1G2H3I4J5k1l",
      "cuid"          : "09876543210|Z0Y9X8W7V6z5y4x3w2v1U0T9S8R7Q6u5t4s3r2q1P0O",
      "site"          : "retailer",
      "clientToken"   : "1234abcd5678",
      "channel"       : "web",
      "lang"          : "en-gb",
      "currentURI"    : "www.retailer.com/basket.html",
      "previousURI"   : "www.retailer.com/product/RC123.html",
      "userAgent"     : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
      "basket"        : {
                        "items"    : [
                          { "refCode" : "RC123", "qty" : 5,  "price" : 50.5 },
                          { "refCode" : "RC124", "qty" : 8,  "price" : 52.5 }
                        ],
                        "currency" : "GBP",
                        "basketId" : "Basket123"
                      }
    }   

Optimizely then associates the basketId with that session and can be passed to the ESP if the session satisfies the rules set up for the trigger campaign.

Steps for the Email Service Provider (ESP)

For the ESP to receive the basketId during the trigger process, notify Optimizely with your intention to use this feature so it can be enabled for your ESP’s integration with Optimizely's service.

After the ESP can accept the basketId variable through Optimizely, the ESP needs to catch the basketId variable that is passed as part of the trigger and use it to create a link to the basket page on your site.

Adestra ESP

The email campaign template includes a button to complete an order, which has a link to the basket on the client site:

https://www.my-site.com.cart?optimizelyBasketId=\_transaction.peeriusBasketId\_

Adestra ESP replaces transaction.peeriusBasketId with the basketId value sent as part of the trigger when sending out the email.

Optimizely ESP for email campaigns

📘

Note

To add a new standard field called externalbasketid to Email Product Recommendations-related recipient lists, contact customer support.

The email campaign template includes a button to complete an order, which has a link to the basket on the client site:

https://www.my-site.com/cart?optimizelyBasketId={externalbasketid}

Optimizely ESP replaces the placeholder _{externalbasketid}_with the basketId value sent as part of the trigger when sending out the email.

Populate the basket with abandoned products

When the user clicks on the link to view their abandoned basket, check the basketId parameter passed with the request and pull the last-known products from your side for that basketId, because Optimizely does not send the abandoned products as part of the trigger.

This process is unique to the setup of your site but you should have the functionality to pull the last-known basketed products for the basketId and add these to the current basket for that user.

Products should match those that the user abandoned.