Storing at Member’s metadata from the registration form Answered
Does anyone know how to store something in a Member’s metadata from the registration form? I need to store the email campaign’s name (that resulted in a certain onboarding journey) as metadata on the member.
Trouble I’m finding:
- Metadata is only set with JS, not with attributes.
- I don’t see how you can set it via JS because they haven’t submitting the register form to create an account at this point.
- Custom fields don’t feel like the right place for this info.
Comments
5 comments
cc Julian Galluzzo do we have any member scripts for this?
cc Julian Galluzzo If you're creating a Memberscipt for this, please keep in mind that Metadata is read-only via the frontend and can only be updated from the backend.
Yep Chukwudi-Onyekwere, I realised after writing, that you can’t update Metadata from JS. I then saw that you can set Custom Fields that don’t exist in the UI and, therefore, they won’t appear in the UI. So I’m looking at that route now. Although, I’m having to use a cookie and updateMember() on the subsequent page load. Not the cleanest approach but it’ll work. Perhaps the ability to set custom fields (which don’t exist in the UI) using attributes on the register form would be a useful addition? I don’t see any mechanism atm for storing meta on a user from registration.
Also, it seems you can’t delete a custom field’s value by setting the value to null . For example: $memberstackDom.updateMember({'customFields': {'campaign': null}}).then(({ data: member }) => { // … }); I haven’t found a value that works at deleting a non-UI field yet. This would be useful for housekeeping. Thanks
That doesn’t work either since the Make “Watch new Members” trigger fires before I can update the Member’s custom field with a value. Still looking for a hero 🤞
Marc Hudson Am i correct that you are trying to pull the email campaign name from a link param? And then pass that into a hidden field which gets saved in Memberstack?
If so, maybe this will help? https://www.memberstack.com/scripts/prefill-form-based-on-url-parameters
and then you can add the hidden custom field to your sign up form. https://docs.memberstack.com/hc/en-us/articles/7842471590811#hide
Hey Duncan, thanks, this is close to my existing code, however after sleeping on it, I remembered that memberstack has a “Hide from Pre-built UI” switch when creating Custom Fields. I know the data-ms-member attribute will work if the Custom Field already exists in the UI, so I managed to set the value by adding that attribute on a hidden form field.
Some thoughts:
Thanks :)
Please sign in to leave a comment.