How to get user's unique session id in Shopify plugins

Solved

How to get user's unique session id in Shopify plugins

ajs540
Shopify Partner
3 0 0

I'm new to shopify

I'm 
developing an app for Shopify.
It consists of three parts: plugin, front-end (non-embedded) app, and backend. Any website/shop built with Shopify has the ability to install our app and integrate our plugin into section of the product page. The plugin basically embeds videos on product page

The problem is that want to perform certain analytics on videos shown via plugins.
I can easily get total views on a video but ...
I want to get unique views per user session. For example, how many distinct user sessions are present and how many views a video receives in each session

Is there a method to distinguish a distinct user session in Shopify so that I may transfer that {sessionId} and the number of views.

- Any shopify API from which I can fetch a unique {sessionID} for every new user session?
- Something already available in localStorage/cookies/sessionStorage etc?

Accepted Solution (1)

BSSCommerce-B2B
Shopify Partner
565 114 137

This is an accepted solution.

Hi @ajs540,

 

- Did you try this? The result is shown below.

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

BSSCommerceB2B_0-1718691362048.png

- The value is stored in cookies

BSSCommerceB2B_1-1718691471752.png

- I cleared site data, and the value is refreshed.

BSSCommerceB2B_2-1718691550314.png

 

I hope this information is helpful to you.

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

View solution in original post

Reply 1 (1)

BSSCommerce-B2B
Shopify Partner
565 114 137

This is an accepted solution.

Hi @ajs540,

 

- Did you try this? The result is shown below.

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

BSSCommerceB2B_0-1718691362048.png

- The value is stored in cookies

BSSCommerceB2B_1-1718691471752.png

- I cleared site data, and the value is refreshed.

BSSCommerceB2B_2-1718691550314.png

 

I hope this information is helpful to you.

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