Shopify themes, liquid, logos, and UX
I have two headers for two business categories, for the common pages such as contact-us, search, etc. I need to track the last page the user was on to know which header to show (header of category 1 or header of category 2). Is there a way to track visited pages in Shopify ?
Solved! Go to the solution
This is an accepted solution.
Hi @ariba-s,
I understand your request, there will be 2 ways for you to do it:
1: You will always show 2 headers and use sessionStorage to check history, then add code to hide or show 1 of the 2 headers.
2: You use the cart properties object to add history and check it with Liquid code, and saving properties is also added by JS fetch.
I hope it helps!
Hi @ariba-s,
You can just use Javascript for it, you can refer to sessionStorage
I hope it helps!
@namphan How can I access the session storage inside the liquid code. The way I do to change the header is like this inside theme.liquid
{% if home_pages contains template %}
{% sections 'home-header-group' %}
{% else %}
{% sections 'header-group' %}
{% endif %}
Hi @ariba-s,
Both headers have links like contact-us, search, etc.
Sorry, I don't really understand your request, can you send me an example and send me the store link? I will check it again
for example contact-us will show the business header if the user was in a business page before clicking contact-us. However, if the user comes from a page of category home contact-us should show the home header.
This is an accepted solution.
Hi @ariba-s,
I understand your request, there will be 2 ways for you to do it:
1: You will always show 2 headers and use sessionStorage to check history, then add code to hide or show 1 of the 2 headers.
2: You use the cart properties object to add history and check it with Liquid code, and saving properties is also added by JS fetch.
I hope it helps!
Thank you @namphan
I am using the first solution and it seems to be working for now. The only thing that I don't like is that I had to create two arrays one for the first category page templates and one for all the common page templates. Which I will have to update manually whenever we add a page to the website. Also, I have to check the href based on a key word connected to the first category. All this make me feel that this solution is not robust even though it's working.
How can I add history to the cart properties object ?
Hi @ariba-s,
You can refer link
I hope it helps!
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025