Jump to content

Add custom fields to customer or member

Go to solution Solved by paul2009,

Recommended Posts

Is it possible to add custom fields to customers or members which I can edit manually in the Profiles area?

Follow-up question, is it possible then to display that information on a page when a customer or member is signed in?

Thanks

Link to comment
  • Replies 9
  • Views 1.5k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution
8 minutes ago, russw said:

Is it possible to add custom fields to customers or members? is it possible then to display that information on a page when a customer or member is signed in?

No. You can only do this by storing custom fields on another (non-Squarespace) system and then pull this information into Squarespace so that it can be displayed. The Squarespace ethos is that your custom information shouldn't be stored on their platform.

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

Link to comment

Thanks for the prompt reply. I guess you know the next question... can you point me in the right direction regarding how I might "pull this information into Squarespace so that it can be displayed"? Would that have to be something like a code block with JavaScript that makes an API call?

I should stress my requirement is to pull from that external source only the data that relates to the member or customer that is signed in. So when the JavaScript or some other mechanism sends the request to the external data source, it's gonna need to send something that identifies the member/customer too.

Thanks.

Edited by russw
Link to comment
4 minutes ago, russw said:

Can you point me in the right direction regarding how I might "pull this information into Squarespace so that it can be displayed"?

In summary, the member's ID would be queried by the third party application as a query and the relevant data (the custom fields) would then be passed back to Squarespace so that it could be injected into the page content. The Profiles API allows apps to retrieve Squarespace end user details.

Of course this is oversimplifying things somewhat! Every requirement will be different.

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

Link to comment

Hi. I appreciate that is oversimplifying it, but I'm an experienced developer so I get what you mean and I appreciate it's not practical to give me a complete solution here. However, I can't find information in the SS documentation about the basics - hence reaching out in this forum. Either I'm not looking in the right place, or it's not possible. That's what I'm trying to figure out.

Your answers are sorta heading in the right direction but I still don't know if what I'm after is possible or whether I'm just missing it in the documentation.

Perhaps if I try a very specific question: Can I add a code block to a SS page with some JavaScript in it that will display the name and ID of the customer that is currently signed in? That would be a good start.

Thanks for bearing with me.

Link to comment
3 minutes ago, russw said:

Can I add a code block to a SS page with some JavaScript in it that will display the name and ID of the customer that is currently signed in?

Yes. You could use JS to call the User Account API to check if the user is authenticated. If they are, you can return their email address, name and customer id.

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

Link to comment

ok, getting there, maybe...

So I'm looking at this page: https://developers.squarespace.com/commerce-apis/retrieve-specific-profiles

But I can't see any API end points that would give me what I want. It doesn't list a User Account API. It does list the Profiles API you mentioned earlier. But the end point requires that I supply a profile ID or an email address. I don't know this information - that's what I'm trying to obtain.

Sorry if I'm just missing something obvious, but I don't see how I can use this. Am I missing something?

Link to comment

I asked a question recently in the Commerce forum, which turned into a chat about JavaScript code and the SS API, so apologies for cross posting but maybe this forum is a better place to ask...

Is it possible to put JavaScript in a code block that will detect whether a customer is signed in and, if so, return their email address? Someone on the other forum said yes using the "User Account API" but I can't find any documentation for that API. They also mentioned the Profiles API which does look like it would allow me to retrieve information about a user but only if I already know the Profile ID, which I don't.

In Settings, Advanced, Code Injection, there's a section at the bottom to inject code into the footer of the order confirmation page after checkout. It lists a bunch of tags I can use in the code which include the user's email address. I was kinda hoping for something like that... are there similar tags I can just drop into JS code in any code block on a SS page?

Some links to appropriate documentation would be great.

Thanks.

Link to comment
  • 1 month later...

I have the same question as russw.  Looking for a way to store and reference additional info about my customers.  If an external db is required--such as sortable--how would I grab the customer ID or email from SS to send through an API call?  Thanks

On 4/6/2022 at 11:38 AM, russw said:

Thanks for the prompt reply. I guess you know the next question... can you point me in the right direction regarding how I might "pull this information into Squarespace so that it can be displayed"? Would that have to be something like a code block with JavaScript that makes an API call?

I should stress my requirement is to pull from that external source only the data that relates to the member or customer that is signed in. So when the JavaScript or some other mechanism sends the request to the external data source, it's gonna need to send something that identifies the member/customer too.

Thanks.

 

Link to comment
  • 2 weeks later...

Using Thunder Client in VSCODE I can send a GET request using an API token I created on the advanced setting page in SS.  However, when I use the js FETCH function and apply the exact same headers with the same token I get a 401 error.  

My example code is below, any ideas on why the 401 error?

        var url = "https://api.squarespace.com/1.0/profiles?sortField=email&sortDirection=asc"
        var apiKey = "Bearer xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
        var userAgent = "myAgent"
 
        var myInit = {
            method: 'GET',                    
            headers: {
                'Accept': '*/*',
                'Authorization': apiKey ,
                'User-Agent': userAgent ,
                'Content-Type': 'application/json',
            },
            mode: 'no-cors',
            cache: 'no-cache',
        }
 
        var myRequest = new Request(url)
 
        fetch(myRequest, myInit)
        .then(response => {
            console.log(`# of profiles: ${Object.keys(response.json).length}`)
            if(!response.ok){
                console.log(`in on error from GET`)
                console.log(`response status: ${response.status}`)
                console.log(`response body: ${response.body}`)
                throw new Error(response)
            }
            return response.json()
        })
        .catch(error => {
           //do some custom error handling
        })
        .then(theJson => {
            console.log(`in on getting json`)
            //build a data table out of the json data
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.