Solved

How to add the email consent in the track api call for ruby?

  • 27 April 2021
  • 3 replies
  • 618 views

Badge +2
  • Contributor I
  • 1 reply

Hello, 

We are trying to add the consent to a profile when an user signs up and creates an account. In the signup form we have a checkbox for email consent.
Its a Ruby on Rails app where we used the klaviyo gem and

Klaviyo::Public.track() 

api call for creating the profile whenever a user is created. Is there any way to add the consent field in the track api call as we need the consent to send emails to the users.

Thank you.

icon

Best answer by Dov 29 April 2021, 15:37

View original

3 replies

Userlevel 7
Badge +61

Hi @ash,

Thanks so much for sharing your question, and exploring the Community for some solutions.

Consent cannot be sent in a Track call since consent requires triggering the opt-in preferences for a specific list (which track events do not engage with at all). You can send consent using the Lists V2 API - this is implemented in the gem.

Thanks and have a great day.

Badge +2

Thanks for the response.

Is it not possible to save the consent for email through legacy form in the database and when calling the track api call send the consent field with properties. Also can you please share a little bit more on sending of consent using Lists V2 API for klaviyo gem.

Thanks!!

Userlevel 7
Badge +61

Hi @ash,

Thanks for your follow-up note.

I’ll take a quick step back to provide some context and then address the sending consent using Lists V2 API for the Klaviyo gem.

There is a $consent field which can be imported as a profile property through a variety of methods (i.e. through list imports, list requests, identify requests, track requests). This is typically used as a tracking field for audit purposes. We have more detail on that in our uploading and segmenting with consent documentation here. I think this is what you’re getting at. 

When Klaviyo refers to “consent” we’re referring to consent as indicated by a “subscribe” which indicates an intentional opt-in to marketing. We track this on a profile as a discrete event rather than as a profile property, and the only way to interact with it is through a “subscribe” request. If you look here under the “Lists” section > "add subscribers to a list, this will follow the lists double opt-in settings" you’ll see an example API call for subscribing a user to a list using the Klaviyo gem. If the list is single opt-in, they will automatically be subscribed.

So in theory you can use either method but the latter is the formal subscription pathway and the former is used for audit purposes.

Thanks and have a great day.

Reply