Sitecore Send Tracking HTTP API

Moosend logo

Review Sitecore Send Tracking API

In previous blog we talked about configuring Abandoned Cart with Sitecore Send. The suggested way to implement tracking is to use Moosend Javascript API. There are some downsides with it:

  • Front end needs to be changed
  • Additional tracking library needs to be imported onto site
  • It's one more JS integration in addition to default set: Google Analytics, Facebook Pixel and etc.

But it's possible to implement it with Sitecore CDP. Unfortunately we can't use Javascript Tracking API there. Instead we need implement Tracking without JS API just with HTTP Requests with required payload sent to Tracking URLs. Lets take a look how to implement it.

Search for sources

The sources of Moosend tracking library can be easily found on Github.

After some investigation of sources we found Tracker.ts and config.ts.

Basically we can see, that requests are made to https://t.stat-track.com host to paths /identify or /track - based on the event type.

Note. It's also file EXAMPLE-0.4.0.md in this repository, but it's outdated: wrong payload is provided there.

HTTP Requests for Abandoned Cart tracking

Now lets review the request made for each type of event required for Abandoned Cart Tracking.

Identify request

This request is made when the user's email is known.

POST https://t.stat-track.com

{
   "ContactEmailAddress":"[USER_EMAIL]",    // users' email
   "ContactId":"[USER_ID]",                 // unique user id
   "actionType":"IDENTIFY",
   "sessionId":"[SESSION_ID]",              // unique session id
   "siteId":"[SITE_ID]"                     // site id from Moosend settings
}

The key thing here is known email and user identifiers:

  • ContactId - unique user identifier, stays the same for multiple user sessions
  • sessionId - unique session identifier, stays the same per particular user's session, but is different per others user sessions.

[USER_EMAIL], [USER_ID], [SESSION_ID] will be used in all others requests. [SITE_ID] is the same for requests for all users in scope of single Moosend integration.

Add to cart request

This request is made when user adds something to the shopping cart.

POST https://t.stat-track.com/track

{
   "ContactId":"[USER_ID]",
   "actionType":"ADDED_TO_ORDER",
   "sessionId":"[SESSION_ID]",
   "siteId":"[SITE_ID]",
   "ContactEmailAddress":"[USER_EMAIL]",
   "properties":[                               // information about added to the cart product
      {
         "product":{
            "itemCode":"[PRODUCT_ID]",          
            "itemPrice":10,                     // product price - decimal
            "itemQuantity":2,                   // added quantity
            "itemTotalPrice":20,                // itemPrice * itemQuantity
            "itemUrl":"[PRODUCT_URL]",
            "itemName":"[PRODUCT_NAME]",
            "itemImage":"[PRODUCT_IMAGE]"
         }
      }
   ],
   "Url":"[CURRENT_PAGE_URL]"
}
Order completed request

This request is made when the order is completed. Also, list of products needs to be included into the payload:

POST https://t.stat-track.com/track

{
   "ContactId":"[USER_ID]",
   "actionType":"ORDER_COMPLETED",
   "sessionId":"[SESSION_ID]",
   "siteId":"[SITE_ID]",
   "ContactEmailAddress":"[USER_EMAIL]",
   "properties":[
      {
         "products":[
            {
               "itemCode":"[PRODUCT_ID_1]",
               "itemName":"[PRODUCT_NAME_1]",
               "itemPrice":10,
               "itemImage":"[PRODUCT_IMAGE_1]",
               "itemUrl":"[PRODUCT_IMAGE_1]",
               "itemQuantity":2,
               "itemTotalPrice":20
            },
            {
               "itemCode":"[PRODUCT_ID_2]",
               "itemName":"[PRODUCT_NAME_2]",
               "itemPrice":20,
               "itemImage":"[PRODUCT_IMAGE_2]",
               "itemUrl":"[PRODUCT_IMAGE_2]",
               "itemQuantity":3,
               "itemTotalPrice":60
            }
         ]
      }
   ],
   "Url":"[PAGE_URL]"
}

Upcoming

In the next articles we will keep reviewing Sitecore Send and we'll start implementing integration with Sitecore CDP.

Sitecore Send Series

Abandoned Cart with Sitecore Send

Sitecore Send Http API