How to get session ID in orders REST API/GraphQL

How to get session ID in orders REST API/GraphQL

ajs540
Shopify Partner
3 0 0

I'm new to shopify.

 

I need a way to map a particular order to user's session. I.e what is the session ID in which that particular orders is placed.
Checking the REST API response of orders, there is no particular mapping like this.
There is a field called `session_hash` but it is mostly NULL value (even if it is not NULL how to decipher hash)

Is there any way to find this

  • Any particular field in Order REST API/GraphQL which can directly give session ID
  • Any custom way, where I can log an event just before checkout API is called for placing a new order
  • Any other hacky way, like combination of broswerIP + userID + <SOME-OTHER-VALUE> to uniquely identify a unique user session in which an order is placed. 


Basically I'm calculating an analytics : (sessions in which an order(s) is placed) vs total unique sessions

-----------

Link to order Rest API : Order (shopify.dev)
For Session ID I'm fetching it via & saving it into my backend: 

ShopifyAnalytics.lib.user().traits().uniqToken

 

Reply 1 (1)

BSSCommerce-B2B
Shopify Partner
565 114 137

Hi @ajs540,

I think the order info does not have any fields related to user's session ID. But, we can put additional info into order note attributes by putting info into cart attributes using Ajax Cart API

 

-> Make a request on Storefront

BSSCommerceB2B_0-1718873033143.png

 

-> Check cart data by storefront-domain/cart.js

BSSCommerceB2B_1-1718873182822.png

 

-> Proceed Checkout and check order data 

BSSCommerceB2B_2-1718873235092.png

 

 

That what I can think about. Hope you can find out solution soon.

If our suggestions are useful, please let us know by giving it a like, marking it as a solution.


B2B Solution & Custom Pricing |BSS: B2B Portal, Quote, Net 30 | BSS: B2B Login Lock Hide Price


Need help from our expert? Kindly share your request with us via community@bsscommerce.com


BSS Commerce - Full-service eCommerce Agency