Is it possible to detect when a visitor/customer just entered my website or leave it (like if a new session is started or closed between the client and the website).
Can it be done in the liquid files? Is there another way that I can detect that?
Eventually I want to send the information to Google Tag Manager with dataLayer.push()
My colleague Elle wrote a great post to a similar thread on viewing visitor/customer starting and closing sessions that you might want to check out: Notification when someone is live on my site.
I am not sure if it’s possible to create a notification within the liquid files from the theme editor as I am not trained in coding and this would be outside our scope of support.
However, I would recommend looking into hiring a Shopify Expert. Shopify Experts are trained experts who can add a customization to your store to enhance its features. Here is our landing page where you can find a list of Shopify Experts.
No, this is not possible to do with Liquid nor even client-side’s Javascript. The best you could get out of client side coding is similar to what “exit intent” apps do, when the user’s mouse goes off screen (or, in other words, they’re about to close the tab) they detect that and show up a message.
To achieve what you’re after you’d need a custom app developed to properly observe the traffic and organize the data accordingly. (e.g. send info to Google Analytics)