Solved

What's the current method for removing email consent via PI?


Userlevel 2
Badge +5

I could only find older answers to this, or ones relating to sms not email.

When customers use their account pages on our site to unsubscribe, I need to synchronise this with their Klaviyo profile.

I have tried doing this with /identify, /profile and even the /exclusions endpoint. None of them actually work. Although the requests go through fine, the profile consent status stays the same.

I have tried setting $consent to an empty array, to false, to null, to ‘None’ and all sorts of variations. I have tried sending ‘email_consent’ => false, ‘$email_consent’ => false, to ‘None’, to null and all sorts of variations on that, too.

Each time the custom ‘updated’ property of the profile is set to the timestamp of the request, so I know it got through, and they’re showing as HTTP 200, returning a 1, all good. But no changes to the profile’s $consent.

How do I actually go about doing this via API please?

icon

Best answer by stephen.trumble 30 June 2022, 02:36

View original

12 replies

Badge +2

Hey, 

Im new here, so might be off track… sorry if so..

what platform is this?

Shopify

I think shopify also syncs a marketing=false/true to the record and will update that field on change (would need to check)? 

Also, if you have shopify, you might be able to use webhooks on customer update as a trigger for this manual update. 

General

You could also write a custom klaviyo event on the page that sends the event on submission of the form to klaviyo 🤷 via an eventlister.

Userlevel 2
Badge +5

Thanks. This is a custom integration for a custom ecommerce site, we don’t use Shopify etc. I’m communicating with Klaviyo via curl requests to their API.

Userlevel 2
Badge +5

Have finally managed to do this via the /exclusions endpoint.

Userlevel 2
Badge +5

Spoke too soon - results are not repeatable in my unit tests, following a resubscribe test, $consent for the test profile now shows as an array with ‘email’, but actual consent remains as the red X showing as not contactable.

Is this a rate limit problem?

Userlevel 7
Badge +60

Hey @dartacus 

Thank you for reaching out for help with this! Thank you @chrisB for jumping in to help! Love to see the collaboration. 

quick question are you using the List API docs to build this? Typically if you set $consent:false it will remove email consent on the customers profile.

Userlevel 2
Badge +5

Thanks Stephen.

I referred to https://developers.klaviyo.com/en/reference/exclude-globally when trying to do the update using my already-developed /track and /identify methods did not work - however I will retest these now setting $consent to false.

For reference, this is a PHP site, I’m using the curl library to send requests.

Userlevel 2
Badge +5

Once again, thanks Stephen. $consent: false is working and my unit tests pass (I would have sworn blind it wasn’t working yesterday, though).

Now I just have to work out the API method to restore consent back to [‘email’] when customers change their account preference back to wanting to receive our emails….

Userlevel 1
Badge +2

@dartacus is that still working for you? I’m calling /identify with $consent: false (not as a string) but also tried [] and “” and null and my test profile is still showing consent for email. 

Like your original issue, the timestamp does update in the UI so I know the API call was accepted.

Userlevel 2
Badge +5

@agrath no, doesn’t work any more, unit tests all fail now. Had to check the results manually, too, because an API call to get the ‘consent’ status just returns an empty array whether my test profile was subscribed or not.

Is there a mod watching who can escalate this? I had thought that this issue was solved, now I come back and find it isn’t and my customer lists are probably very out of sync with Klaviyo, which has serious customer satisfaction implications for me as our delivery charges are different depending on whether someone is a subscriber or not. I *have* to have a good sync between my database and Klaviyo.

Userlevel 1
Badge +2

@dartacus at the very least, I’m glad I alerted you to a problem :)

I was reading your original comments and thinking I must have missed something as you said it was working for you - but since your unit tests are now failing I guess the API has changed.

I have created an issue of my own if you’d like to add a +1 there

https://community.klaviyo.com/topic/show?tid=5706&fid=64

In short, to summarize on this ticket, I am trying synchronise _general_ consent (as I think you are as well) not to a specific list

 

Badge +1

Im using https://a.klaviyo.com/api/identify  

I tried  "$consent": "false" is not working. Could any one help

Thanks

Userlevel 1
Badge +2

@Aaron can you add to this one? 

 

Reply