POST https://transactions.littledata.io/v2/clientID

This API is used by Littledata’s Shopify Tracker to link the client browsing with the Shopify cart token.

This works for 95% of Shopify stores, but in custom themes where a user can buy straight from the landing page and checkout it is necessary to post the data to Littledata in callback – after the user has a cart token created but before the user is directed to checkout on another domain.

This clientID – cartID pair must be sent for every user navigating to checkout, regardless of whether they pay during that session.

After the checkout is completed, and Shopify processes the order, Littledata’s server will then match the cartID when the one sent from Shopify’s order web-hook – and so link the web session with the eventual payment.

Request

The HTTP header should be set to Content-Type: application/json.  This POST method requires two parameters in the JSON body: always the cartID and then one of the platform clientIDs

  • cartID: cart token generated by Shopify when an item is added to cart
  • google-clientID : user identifier stored by Google Analytics cookie and accessed via the GA tracker object
  • segment-clientID: anonymousID created by AnalyticsJS library and stored in localstorage

Response

A 200 HTTP response indicates the clientID and cartID have been accepted.

Example

Here is an example of how to POST JSON to the endpoint using JQuery, after the Shopify cart has been updated.


jQuery.post('/cart/update.js', { updates: { 123456: 1 } }, function(cart) {
    ga(function() { //wait for ga library
        var clientID = ga.getByName('littledata').get('clientId');
        jQuery.post('https://transactions.littledata.io/clientID', {
            clientID : clientID,
            cartID : cart.token //returned from cart update
        })
    });
    // continue the redirect to checkout

});