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
1972 564 568

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.

B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.


B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.


B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.


BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now

View solution in original post

Reply 1 (1)

BSSCommerce-B2B
Shopify Partner
1972 564 568

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.

B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.


B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.


B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.


BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now