Liquid, JavaScript, themes, sales channels
Hi everyone,
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()
Thanks
Hey, @TomCalmigo.
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.
Is this what you were looking to do?
To learn more visit the Shopify Help Center or the Community Blog.
The idea is the same, but I prefer to get notification about it from the liquid files of the theme and not from an external app.
Eventually I want to send an event from the liquid file (for example theme.liquid) as dataLayer.push to Google Tag Manager and Google Analytics 4.
Can it be done from the liquid files?
Thank you for clarifying, @TomCalmigo.
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.
Does anyone else have some insights?
To learn more visit the Shopify Help Center or the Community Blog.
@TomCalmigo
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)
Kind regards,
Diego
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024