DEV Community

Medam Mahesh
Medam Mahesh

Posted on

How to store user data in Shopify App ?

Hi,

I have recently started looking into shopify app development. I know how to build UI for Shopify App for now.

My App Idea uses an API which provides an api_key.

Now when a Shopify Customer installs my app, he enters this API key on the Frontend Form that I had created and tries to submit.

DOUBT

How and where to store this information ? How to retrieve this information once saved ?

I have been burning the midnight oil for this. So, if any experienced people are present. Please lend me a hand.
I am very much willing to clarify any doubt in my explanation.

Thanks in advance,

Top comments (12)

Collapse
 
brandinchiu profile image
Brandin Chiu

Your web application is responsible for storing its own information. This typically means a database that backs your service in some way.

Essentially, you are building a regular ol' boring web application, with the fundamental difference being that you're integrating Shopify APIs, and your web all gets loaded inside a Shopify Store.

But otherwise all the other rules for web applications remain.

Collapse
 
memahesh profile image
Medam Mahesh

But I need something to map a customer with my database, right. How to do that ?

Collapse
 
brandinchiu profile image
Brandin Chiu

You have a few different ways of doing that. You can NOT store that information yourself, and rely on Shopify, using their customer api to register and manage users.

Or, you can tap into what's called "multipass" which is a premium feature which provides apis for your Shopify application to sync users between your app and Shopify.

The latter option requires a Shopify plus subscription however, which is very expensive for most store owners.

Thread Thread
 
memahesh profile image
Medam Mahesh

What about metafields at store level ? Would it work ?

Thread Thread
 
brandinchiu profile image
Brandin Chiu

That's for storing data related to an object. It would be an inappropriate place to store customer data.

Thread Thread
 
memahesh profile image
Medam Mahesh

Using Customer API is not an option for me. As the data I want to save is about the store itself (Here, Shopify store is my customer, not the people who buy at store).

Thread Thread
 
brandinchiu profile image
Brandin Chiu

What information are you looking to persist?

Thread Thread
 
memahesh profile image
Medam Mahesh

An api_key from a third-party service for the store

Thread Thread
 
brandinchiu profile image
Brandin Chiu

That would probably be a bad idea. if I remember correctly, metafields are considered a public object, which means any sensitive data should not be stored on them.

An authorization key for another service is very likely not something you would want to be publicly accessible.

You're going to need your own database to link these two records together (this API key and the shopify store).

Thread Thread
 
memahesh profile image
Medam Mahesh

I read something about metafields saying that they can be made private. And then they will only be accessible to the corresponding app only.

Thread Thread
 
brandinchiu profile image
Brandin Chiu

Maybe my information is out of date or incorrect then.

Collapse
 
ercules76 profile image
Ercules76

I am interested in this discussion. I am making an app that needs to do the same thing and that is to record a transaction id in cookies in order to hook a conversion to a publisher. Have you been able to find a solution?