I am having trouble collecting SMS consent with a legacy form using the API documentation for reference.
This previously posted question (Collect SMS consent with legacy form) highlights the same issues I am currently facing, though the provided answers does not seem to be the solution in this case:
- The phone number entered is a valid US number
- Double-opt-in is disabled for the list
- The account does have SMS set up and enabled.
Here is the script for reference:
let klaviyoSubscribeURL = "https://manage.kmail-lists.com/ajax/subscriptions/subscribe";
const data = {
g: "VXXXXS",
'$fields': '$source,$email,$consent_method,$consent_form_id,$consent_form_version,phone_number,sms_consent,$consent',
'$list_fields': '',
'$timezone_offset': Math.abs(new Date().getTimezoneOffset() / 60),
'$source': '$embed',
'$email': email,
'$consent_method': 'Klaviyo Form',
'$consent_form_id': formId,
'$consent_form_version': 524456,
'phone_number' : phone,
'$consent' : s'sms'],
'sms_consent': true
};
fetch(klaviyoSubscribeURL, {
"method": "POST",
"mode": "cors",
"credentials": "omit",
"headers": {
"access-control-allow-headers": "*",
"content-type": "application/x-www-form-urlencoded; charset=utf-8"
},
"referrer": location.href,
"referrerPolicy": "no-referrer-when-downgrade",
"body": Object.keys(data).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(dataekey])}`).join('&')
})
.then(res => res.json(), (res) => {
// console.log(res);
return res.json();
})
.then(data => {
if (data.success) {
heading.html(headingSuccess);
$(this).hide();
errorsBlock.hide();
subheading.html(subheadingSuccessEmail);
emailInput.val("");
emailInput.parent().removeClass("input-group--label-shifted");
}
})
When I export the the profile data, it seems to be missing the sms_consent data object:
{
"object": "person",
"id": "01XXXXXXXXXXXXXXXXXXXXN672",
"$address1": "",
"$address2": "",
"$city": "",
"$country": "",
"$latitude": "",
"$longitude": "",
"$region": "",
"$zip": "",
"$title": "",
"$email": "sXXXXXXX6@gmail.com",
"$organization": "",
"$first_name": "",
"$last_name": "",
"$phone_number": "(310) XXX XXX6",
"$timezone": "",
"$id": "",
"$source": "$embed",
"$consent": o
"sms"
],
"$consent_timestamp": "2022-11-10T00:20:14.517Z",
"Newsletter Signup": "2022-11-09",
"email": "sXXXXXXX6@gmail.com",
"first_name": "",
"last_name": "",
"created": "2022-11-10 00:20:15",
"updated": "2022-11-10 00:20:44"
}
Is it still possible to collect SMS consent in this way?