I’m trying to add custom metadata to customer profiles when they log into my Shopify store. I’ve been searching through documentation and community posts but haven’t found a clear solution yet.
I came across some API examples that show how to attach additional data to customers, but I’m not sure how to implement this in my theme files. Here’s a sample of what I found:
Can someone explain how to properly use this API call within a Liquid template? I need to store some extra customer information when users sign in to their accounts.
Hit this same problem last year building a loyalty program. Liquid templates can’t make server-side API calls - it’s a security thing. I ended up using Shopify’s GraphQL Admin API through a serverless function. When customers log in, an AJAX request hits my endpoint and creates the metafield. You could also try Shopify Flow or apps like Mechanic - they’ll auto-create metafields based on what customers do. Bottom line: you need something server-side between your theme and Shopify’s API. Could be a custom app, webhook, or middleware - whatever works for your setup.
You’re hitting the same wall most of us do when starting Shopify customizations. That Ruby API code won’t work in themes - it’s for server-side apps only. You need either a private app with API credentials or the REST Admin API through middleware. I solved this by building a custom app that handles metafield operations, then calling it with AJAX from my theme. You could also use Shopify’s customer events and webhooks to auto-populate metafields when users do specific things. Just remember - creating metafields needs admin API access, so you can’t do it directly from the storefront (security reasons).
hey mike, just a heads up - you can’t directly call the shopify api from liquid templates, it’s for security. that ruby code needs to be on your backend or using webhooks. maybe try building a shopify app or a custom backend integration instead!
if u have access to shopify plus scripts, definitely use those! but if not, shopify functions are a good alternative. they make updating customer data much simpler than going through the webhooks mess.
Everyone’s right about needing server-side, but here’s what actually worked for me in this exact situation.
I built an automation workflow that handles customer metafields without custom apps or serverless functions. The key is using webhook events to trigger metafield creation automatically.
When customers log in or do specific actions, I capture those events and route them through an automation platform that connects directly to Shopify’s Admin API. The workflow listens for customer events, processes the data, and creates metafields in real time.
This killed the need for middleware servers and custom app development. Plus I can change the logic anytime without touching code or theme files.
The automation handles authentication, API rate limits, and error handling automatically. Way cleaner than managing AJAX calls and custom endpoints.
For your case, you’d set up triggers based on customer login events, then map the data to metafield creation actions. Takes about 10 minutes to configure.
Latenode makes this whole process super simple with their Shopify integrations and webhook handling: https://latenode.com