SFMC Abandon Cart Implementation, Its all "String" parameters in JSON.

Introduction:

In a recent client implementation of an abandon cart behavioral trigger, our team encountered unexpected challenges with product alignment in the email. The client had a specific sorting logic for product display, and despite a seemingly flawless implementation flow, the products appeared misaligned in the email during testing. This led us on a journey of debugging and discovery, ultimately revealing a crucial detail in the payload structure that resolved the issue.


Implementation Flow:

  1. Data Collection with Collect.js: The process began with Collect.js tracking the client's commerce website cart details and transmitting the data to Salesforce Marketing Cloud (SFMC).
  2. Catalog Feed Automation: An automation was set up to update the Einstein catalog daily, ensuring the latest product information was available for recommendations.
  3. Behavioral Trigger Setup: SFMC was configured to write the collected data to a data extension, serving as the source for triggering customers into the abandon cart journey.
  4. Custom Product Sorting Script: Instead of using out-of-the-box (OOB) content blocks, a complex script was developed to fetch, sort, and display products according to the client's specific requirements.


Issue Discovery:

During testing, it became evident that the products in the email were not aligning as expected. The investigation led us to scrutinize the sorting logic, API calls, and the data retrieved from the Einstein recommendations.


Surprising Revelation:

The root cause of the misalignment was unexpected—the payload structure. Although the product details and SKUIDs were accurately captured during website tracking, the Einstein recommendations were not reflecting the correct cart information.


Resolution:

Our breakthrough came from an article titled "Einstein Recommendations 'An item not in the catalog was viewed' in the status console, but item exists in catalog", which highlighted a crucial detail: all parameters in the JSON payload should be treated as strings.


Original Payload:

{

   "cart":[

      {

         "item":11004743,

         "quantity":1,

         "price":3.48,

         "unique_id":10008760

      },

      {

         "item":11021908,

         "quantity":1,

         "price":268.99,

         "unique_id":10096943

      }

   ]

}


Corrected/Required Payload:

{

   "cart":[

      {

         "item":"11004743",

         "quantity":"1",

         "price":"3.48",

         "unique_id":"10008760"

      },

      {

         "item":"11021908",

         "quantity":"1",

         "price":"268.99",

         "unique_id":"10096943"

      }

   ]

}

No comments:

Post a Comment

Powered by Blogger.