Hi,
I have a subscriber form on my site, with an “opt in to marketing” checkbox. I would like the checkbox to update the subscription status of the contact using wix-crm, however, there is no existing parameter to do this via code. The work around is to create a custom field. This seems like something which could be difficult to manage later on. This is the closest existing thread on the topic - https://www.wix.com/code/home/forum/community-discussion/add-subscriber-checkbox-to-wix-forms - but it has been left unresolved.
This is the current code from the API reference, which has no reference to the subscribe option in the pre made contacts collection:
let firstName = // get first name
let lastName = // get last name
let email = // get email address
let phone = // get phone number
wixCRM.createContact( {
“firstName”: firstName,
“lastName”: lastName,
“emails”: [email],
“phones”: [phone]
} )
- Is this actually possible right now, and if so what is the key/value pair?
- If it isn’t, can someone from Wix let me know if it is in the roadmap.
You can either do it through Wix Forms with adding a subscriber opt-in checkbox, or you can do it yourself through Wix or own datastet, with or without any additional code that you want to use.
Either add the field to your own dataset for subscriptions, marketing consent etc, or just add a custom field to the wix private members dataset. The custom field can be named whatever you want, however the field value must be set to boolean.
https://support.wix.com/en/article/adding-a-subscriber-opt-in-checkbox-to-your-form
https://support.wix.com/en/article/tutorial-how-to-get-explicit-opt-in-consent-from-your-users-using-wix-code
Thank you. I was trying to find a solution which uses the wix-crm, but it seems like this hasn’t been integrated into Wix code yet. These work arounds appear to be the only options.
trying to do this myself. surely there must be a field key: value pair for the wix subscribers form to provide the data to wix-crm but I’ve tried loads of options/combinations so far in my code but no success so far. please update this thread if you find out how or if this is actually achievable without custom fields etc.
@joe1pratt [@Paul Floyd]
To use the Custom Fields in the CRM you have to define the field first in the Dashboard and the type of the field must match the JavaScript type you are working with. So first create your Custom Field.
Go to Customer Management in the Dashboard:
Open the Manage Custom Fields dialogue:
Add a new field:
Choose the field type and give it a name. When accessing the field in code make sure that the values you use exactly match name and type (see below):
In the example below the # agreeToConditions element is a checkbox . It has a true or false value in its checked property. As we know from the Custom Field definition above we need to have a text field (a String). So in the addToCRM event function code below we add the Custom Field as one of the properties of the contactInfo object we create to pass to wixCrm.createContact .
Note: The checked property is tested and a string, “true” or “false” , is set on the contactInfo property “Agree To Conditions” . When createContact is executed this will be saved in the CRM.
Here’s the result:
Good luck!
Cheers
@stevesoftwareservice Thanks for the detailed walk-through. It’s very kind of you to take the time to put this together.
I decided not to use Wix CRM in the end and created my own collection. The original question was specifically referring to the existing subscriber field built into the Wix CRM collection, and if it was possible to save the customer’s contact preferences without creating custom field. It seems bizarre to have this field in the collection, yet not provide a way of setting it through the API.
Still no response from Wix on this, so i’m assuming it’s not a priority for them.
@joe1pratt No problem Joe. Yes it is an issue I have highlighted a number of times with the product team. The relationship between CRM and Site Member (Users) is not always clear and the ability to manipulate fields in an admin role from the site vs. dashboard. It is often easier to create a custom collection to manage properties you need that aren’t in the standard CRM model. The main focus for the CRM is building enough contact information to drive Ascend Marketing Tools like Automations etc.