Detect when visitor entering/leaving my website

TomCalmigo
Shopify Partner
21 0 1

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

Replies 4 (4)

Tira
Shopify Staff (Retired)
1260 90 223

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.

TomCalmigo
Shopify Partner
21 0 1

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?

Tira
Shopify Staff (Retired)
1260 90 223

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.

diego_ezfy
Shopify Partner
2958 568 891

@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