Does an API for getting number of sessions or visitors exist?

LouiseEH
Shopify Partner
29 3 4

Hi,

 

I've been looking into the ShopifyQL API c.f. https://shopify.dev/docs/api/shopifyql in relation to getting the number of sessions or the number of visitors for a given time period.
As far as I can see, you can only query data about orders, products or payments in the ShopifyQL API. For products you can query different metrics about sessions e.g. view_sessions and cart_sessions, but always in relation to the product as opposed to sessions or visitors in general.
From previous posts it looks like there might have been a session metric in the ShopifyQL API earlier on, but not anymore. Or maybe I can find the information in another API entirely?

Kind regards,
-Louise

Replies 9 (9)

made4Uo
Shopify Partner
3806 713 1129

The ShopifyQL API does not include user sessions. However, you can definitely use other language to detect users and log sessions

Volunteering to assist you!  Likes and Accept as Solution  is highly appreciated.✌
Coffee fuels my dedication. If helpful, a small Coffee Tip would be greatly appreciated.
Need EXPERIENCED Shopify developer without breaking the bank?
Hire us at Made4Uo.com for quick replies.
Stay in control and maintain your security by avoiding unnecessary store access!
InnaB
Visitor
3 0 0

What would be a good workaround?

When talking about "sessions"  usually what people here are referring to is even aggregated data about how  many times a product page has been viewed.Is that possible?

What about creating a developer app for shopify plus merchants that will call shopifyql API?

There is documentation saying that there might be a way, for example:

https://shopify.dev/docs/api/shopifyql/datasets/products-dataset

LouiseEH
Shopify Partner
29 3 4

Hi InnaB,

 

Thank you for your reply.
Yes I did see the products dataset in ShopifyQL, but it only refers to sessions for a specific product, but I am interested in sessions overall, i.e. not only related to a specific product.

 

LouiseEH
Shopify Partner
29 3 4

Update: I would prefer getting the exact same number of visits/sessions as from the Shopify Analytics report.
So even though I could calculate a number via other non-Shopify APIs og maybe with the Shopify web pixel API, I would prefer to use exactly the same data as what is accessible in the Shopify analytics reports

InnaB
Visitor
3 0 0

From what I understood from Shopify, you can't access session data through an API like you can through the interface.Ive been researching this subject for a while.

I am interested to know if you did manage to pull product data set sessions with ShopifyQL.

 

 

LouiseEH
Shopify Partner
29 3 4

Ah ok.
I did not try because it is not the data I am looking for.
But I guess something like below would do the trick:

query {
    shopifyqlQuery(query: "FROM products
    SHOW
    sum(gross_sales),
    sum(view_sessions)
    SINCE -7d") {
      __typename
      ... on TableResponse {
        tableData {
          unformattedData
          rowData
          columns {
            name
            dataType
            displayName
          }
        }
      }
      parseErrors {
        code
        message
        range {
          start {
            line
            character
          }
          end {
            line
            character
          }
        }
      }
    }
  }



made4Uo
Shopify Partner
3806 713 1129

Shopify uses Google analytics data. Might as well use the Google api if that is what your looking for 

Volunteering to assist you!  Likes and Accept as Solution  is highly appreciated.✌
Coffee fuels my dedication. If helpful, a small Coffee Tip would be greatly appreciated.
Need EXPERIENCED Shopify developer without breaking the bank?
Hire us at Made4Uo.com for quick replies.
Stay in control and maintain your security by avoiding unnecessary store access!
LouiseEH
Shopify Partner
29 3 4

Thank you for your reply.
Ok that is interesting - where did you find information about that?

made4Uo
Shopify Partner
3806 713 1129

Information is the same as the Google analytics info

Volunteering to assist you!  Likes and Accept as Solution  is highly appreciated.✌
Coffee fuels my dedication. If helpful, a small Coffee Tip would be greatly appreciated.
Need EXPERIENCED Shopify developer without breaking the bank?
Hire us at Made4Uo.com for quick replies.
Stay in control and maintain your security by avoiding unnecessary store access!