How to track visitor activity without login

DianeDouglas
Tourist
4 0 0

Hi guys, I'm hoping to track user interaction on a shopify site but I don't want to be limited to customers with accounts or orders. I want to see analytics info about what products they are clicking on, their landing page etc. 

 

The CustomerJourney and CustomerVisit objects in the Shopify Admin GraphQL API and look like they hold the data I'm interested in, such as referral URL, click history etc. But it seems these are only attached to an Order, which must be placed.

 

Progress so far:

 

I have a basic app set up using the shopify_rails engine, and I have a script tag on my site that grabs cart data using the Ajax API. 

jQuery.getJSON('/cart.js', function(cart) {
    console.log(cart);
});
I'm hoping to get something similar to this for users where I can get info about the current user's session. I'd be happy if it was on every page load, or if it was something that I poll myself every so often. 
 
I've seen that there is a unique token generated for a user that is not logged in as soon as you navigate to a site. You can get this in the javascript console from ShopifyAnalytics. Could this be helpful in looking up a user and tracking their interaction during a visit? 
 
ShopifyAnalytics.lib.user().traits().uniqToken
=> "f4010cd6-06b6-4e6f-a18e-69b6924271ea"
Any insight appreciated. 
0 Likes