Solved

Collect SMS consent with legacy form

  • 15 June 2021
  • 6 replies
  • 472 views

Badge +1

I’m trying to collect SMS consent on a legacy form submitting to https://manage.kmail-lists.com/ajax/subscriptions/subscribe

 

From the API documentation, I’ve tried to collect the consent with the following data objects:

 

$consent: ["sms"],
phone_number: customers_number
"sms_consent": true,

 

In the API documentation I see that it specifies "sms_consent": True with a capitalised True. But if I use that in this context the script is expecting a variable so I’ve used a lowercase true

 

But this doesn’t seem to work with the subscription ajax. If it possible to collect SMS consent this way?

 

Heres my full script for reference:

 

$.ajax({
async: true,
crossDomain: true,
url: "https://manage.kmail-lists.com/ajax/subscriptions/subscribe",
method: "POST",
headers: {
"content-type": "application/x-www-form-urlencoded",
"cache-control": "no-cache"
},
data: {
g: klaviyo_list,
$fields: "$source, $consent, email, phone_number, sms_consent, $first_name, $last_name, Shopify Tags, Accepts Marketing",
$source: "Footer",
email: emailaddressVal,
$consent: ["sms"],
phone_number: $form.find('.k_id_phone').val(),
"sms_consent": true,
$first_name: $form.find('.k_id_fname').val(),
$last_name: $form.find('.k_id_lname').val(),
'Shopify Tags': custPreferences.toString(),
'Accepts Marketing': true
},
success: function(response){
//console.log(response)
$('#newsletter-popup .header').hide()
$form.html("<div class='email-success'><h3>SUCCESS.</h3>"+success_message+"<p><b>"+success_code+"</b></p></div>")
}
});

 

icon

Best answer by David To 17 June 2021, 15:39

View original

6 replies

Userlevel 7
Badge +55

Hi @TheSuburbs,

Thanks for your posting your question here.

The phone number field should have a “$” before it since it is a default Klaviyo property. Otherwise this looks pretty good.

Generally speaking the fields you’ll need are:

  1. email
  2. $phone_number: +12312312312
  1. sms_consent: true
  1. $source: XXXXXXXXX

I hope that helps.

Badge +1

Thanks for your help so far @dov.derin — I’ve just tried ‘$phone_number’ in the data object but it still doesn’t seem to be saving the SMS consent. The SMS consent should be displayed below the email address in Channel right? (see screenshot below).

 

It seems both phone_number and $phone_number save the phone number to the Klaviyo property, although when it is saved with $phone_number the number is prefixed with + and the country code.

 

 

 

 

 

I’m aware that SMS can only be used on Klaviyo with US numbers so I was wondering if consent could only be gathered from US numbers. But I’ve tested that but still no luck:

 

 

Userlevel 7
Badge +53

Hello @TheSuburbs,

Adding to @dov.derin’s great suggestion, can you confirm if that Los Angeles number you are using of +15555551238 is a valid phone number? If this number is not valid and you had double opt-in enabled on the list you are pushing this number to, then this profile/phone number would be unable to confirm their subscription for SMS consent from the text sent to them. 

@spacedeveloper actually had this same issue and shared it with the Community as well in their post below: 

Have a great day!

David

Badge +1

Thanks for the follow up @david.to . Yes defiantly looks like the double opt-in could be one of the issues here although I’ve just tried turning off double opt-in and retesting but I’m still not having any luck.

 

Also when I export the profile data, it doesn’t include the $consent or sms_consent data objects like when @spacedeveloper exported their data with double opt-in still enabled. So it looks like the SMS data isn’t being saved to my profile at all:

 

{
"object": "person",
"id": "01F7VRSXXXXXXCX7APST75HNE",
"$address1": "",
"$address2": "",
"$city": "Los Angeles",
"$country": "United States",
"$latitude": 34.0544,
"$longitude": -118.244,
"$region": "California",
"$zip": "",
"$email": "xxxxxxx@gmail.com",
"$first_name": "Test",
"$last_name": "Testerson",
"$organization": "",
"$title": "",
"$phone_number": "+11234567890",
"$timezone": "America/Los_Angeles",
"$id": "",
"$source": "Footer",
"Shopify Tags": "Kids,Baby,Womens,Homewares",
"Accepts Marketing": "true",
"email": "xxxxxxx@gmail.com",
"first_name": "Test",
"last_name": "Testerson",
"created": "2021-06-10 20:11:05",
"updated": "2021-06-17 20:37:42"
}

 

 

 

Userlevel 7
Badge +53

Hey @TheSuburbs,

Can you confirm if you’ve enabled and set up SMS within your account? If SMS is not yet set up within your account, then you would not see the sms_consent data object when exporting the profile data. You can find instructions on how to enable and set your account up for SMS from the instructions found in the How to Set Up SMS article Klaviyo offers. 

David

Badge +1

@david.to I’ve just checked the account again and we now have one sms subscriber so it looks like our signup form is working. Thanks everyone for the help!

Reply