Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hi Community,
I'm working with Shopify's web pixel integration and subscribing to analytics events (e.g., "page_viewed"). However, the event data object is coming through empty, so I'm unable to access logged-in user information. My goal is to reliably get the currently logged-in user's details (like email, customer ID, etc.) from within my pixel script.
Is there a recommended way to access the logged-in user data in this context, or a workaround if the event data is empty? Any best practices or examples would be appreciated!
Thanks in advance!
Hi @Dev7,
Shopify’s web pixel events often don’t include detailed user info like email or customer ID directly in the event payload due to privacy and security reasons. To reliably get the logged-in user data inside your pixel script, the best practice is to expose this data yourself in the storefront, usually by embedding it in the page’s Liquid template. For example, you can add a JavaScript snippet in your theme’s Liquid files that sets a global variable with the logged-in customer info if available:
<script>
window.loggedInCustomer = {{ customer ? customer | json : 'null' }};
</script>
Then, your pixel script can read from window.loggedInCustomer to get the customer’s email, ID, or other info. This approach ensures you have access to user data on the client side without relying solely on pixel event payloads, which are often minimal. Just be mindful of privacy and don’t expose sensitive data unnecessarily.
Thanks!
Thank you for the suggestion! Injecting the customer data using Liquid like this
does work well, but it will only work for the specific store where this code is added to the theme files. If you want this to work for all stores using your pixel, each store admin would need to manually add this snippet to their theme’s Liquid files.
For non-technical store admins, this can be quite complex and error-prone, since editing theme code is not always straightforward and can risk breaking the store’s layout if done incorrectly.
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn 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, 2025