.... <div class="form-group"> <label for="interests" class="col-sm-3 control-label">Please state your reason for unsubscribing:</label> <div class="col-sm-9"> <div class="radio"> <label> <!-- Default value. --> <input type="radio" name="unsubscribe_reason" value="received" {% if person.unsubscribe_reason == 'received' or request.POST.unsubscribe_reason == 'received' %}checked="checked"{% elif not person.unsubscribe_reason and not request.POST.unsubscribe_reason %}checked="checked"{% endif %} /> I received too many emails </label> </div> <div class="radio"> <label> <input type="radio" name="unsubscribe_reason" value="relevant" {% if person.unsubscribe_reason == 'relevant' or request.POST.unsubscribe_reason == 'relevant' %}checked="checked"{% endif %} /> The content is not relevant to me </label> </div> <div class="radio"> <label> <input type="radio" name="unsubscribe_reason" value="never" {% if person.unsubscribe_reason == 'never' or request.POST.unsubscribe_reason == 'never' %}checked="checked"{% endif %} /> I have never subscribed to this mailing list </label> </div> <div class="radio"> <label> <input type="radio" name="unsubscribe_reason" value="promotion" {% if person.unsubscribe_reason == 'promotion' or request.POST.unsubscribe_reason == 'promotion' %}checked="checked"{% endif %} /> Signed up during a promotion and I am no longer interested </label> </div> <div class="radio"> <label> <input type="radio" name="unsubscribe_reason" value="emails" {% if person.unsubscribe_reason == 'emails' or request.POST.unsubscribe_reason == 'emails' %}checked="checked"{% endif %} /> Difficulty viewing emails on my device </label> </div> </div> </div>
Thanks!
Page 1 / 1
Hi there @coljung,
Thanks for posting your question to the Community!
So unfortunately, Klaviyo does not currently offer services to help build out custom code, nor do we provide support for custom code troubleshooting. However, looking at your code I am not seeing any syntax errors that might be causing it. The custom property should appear as an option (as long as people have submitted responses) when trying to create a segment or create definitions. If it is not being pulled properly, I would speak with your developer to see if they can fix the code.
Apologies for the inconveniece,
Alex
Hi there @coljung,
Thanks for posting your question to the Community!
So unfortunately, Klaviyo does not currently offer services to help build out custom code, nor do we provide support for custom code troubleshooting. However, looking at your code I am not seeing any syntax errors that might be causing it. The custom property should appear as an option (as long as people have submitted responses) when trying to create a segment or create definitions. If it is not being pulled properly, I would speak with your developer to see if they can fix the code.
I’m THE developer, and have trouble making any changes for that code work. The moment I change any of the variables, it stops working. I also checked with my backend devs and they are also confused.
I understand the ‘its a hosted page so we can’t help you’. But the one example you have isnt explained at all.
There are 2 confusing parts in your example code:
The hidden inputs are not explained and I have tried adapting them. To no avail.
Also, EmailFrequency seems to have some predefined values somewhere in your backend, so the moment i change those to my custom options, it stops working.
So, I dont expect you to provide me with a custom page.. but i need some guidance because your only example on how to achieve this has zero explanation.
Thanks
Hi @coljung,
Thank you for your feedback regarding our documentation. We apologize for the lack of clarity on our end and I have gone ahead and communicated to our docs team about that article you linked. Unsubscribe function does not support setting custom properties for profiles. The design in our documentation you had linked was only meant for preferences pages. But there is a workaround we can try.
The first step is to make the form execute custom javascript that would perform an identify call like below:
To note, for hosted pages feature to be enabled on a customer’s site, you would have to reach out to support to get assistance with this. I have gone ahead and made a ticket regarding this for you.
Thank you again for bringing insight regarding this issue and I hope that we can reach a solution.
Alex
Hello and sorry for the delay.
Because of the holidays i postponed a bit working on this again, but I tried again yesterday.
I tried your code, did a bunch of tests… and still have a few issues.
A few things are happening. If you have some adblocker enabled, it wont load some of the scripts.
Once I disabled mine, page loaded without errors.
But then when i submit the form, im getting a bunch of errors that seem out of my control:
Last point, you had mentioned creating a ticket regarding this, which was 22 days ago. So far I have not been contacted in any way from anyone from Klaviyo regarding this issue.
Thanks a lot again and any help will be greatly appreciated.
P.
@coljung I found a workaround for this -- I’m not a developer but maybe this will help you?
I had the same issue: when I created the custom unsubscribe page, and added a list of reasons to select why they are unsubscribing, the custom profile property would not update once a user unsubscribed.
Therefore, the user would unsubscribe, but the unsubscribe reason would not post to their account as a custom profile property.
I used a lot of trial and error to come to the conclusion to treat the page with the idea of a multi-submit form -- but then actually splitting the two sections (unsubscribe reason selection and unsubscribe checkbox) into two separate forms, where upon submitting the first form reveals the second. Because of this, the unsubscribe reason selection must come first. rNOTE: I used Klaviyo’s base code for custom unsubscribe page, found here: https://help.klaviyo.com/hc/en-us/articles/115005077067-How-to-Custom-Code-an-Unsubscribe-or-Manage-Preferences-Page ]:
Add the unsubscribe reason selection in one <form> and the actual unsubscribe checkbox in a separate <form>; Note: both forms will need the email field (I just changed the label for the second one to “Confirm email address”)
The unsub reason form will have to come first
After the unsub reason form, put in a hidden iframe:
The unsub reason form then needs to have a target of the iframe, so add target=”formresponse” to your unsub reason form
To make it extra user-friendly, I also added an onclick to the unsub reason form button so that onclick it would hide the unsub reason form (put it in a div, used javascript function to hide on click), as well as to reveal the unsubscribe checkbox form (so it’s hidden until they submit their unsubscribe reason) (put the unsubscribe checkbox form in a div, used javascript function to reveal on click)
function ReasonSubmit() { document.getElementById("UnsubDiv").style.display = ""; }
function HideTop() { var x = document.getElementById("hideDIV"); if (x.style.display === "none") { x.style.display = "block"; } else { x.style.display = "none"; } }
Surround the unsub reason form with <div id=”hideDIV”> Make sure to start the div just before the unsub reason form, and don’t forget to close off the div (</div) AFTER the unsub reason form only.
Surround the unsub checkbox form with <div id=”UnsubDiv”> Make sure to start the div just before the unsub checkbox form, and don’t forget to close off the div (</div) AFTER the unsub checkbox form only.
Here is the FULL HTML, it’s Klaviyo’s example edited to include the above; but PLEASE NOTE that because of my trial and error, there may be some unnecessary code in there because I’m a novice -- it’s working fine for me though! Now I have created segments in Klaviyo where the properties equal each of the Unsubscribe reasons so I can see why people are unsubscribing. :D
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <style type="text/css"> /* Space out content a bit */ body { padding-top: 20px; padding-bottom: 20px; padding-left: 20px; padding-right: 20px; font-family: 'Neue Helvetica', sans-serif; }
function ReasonSubmit() { document.getElementById("UnsubDiv").style.display = ""; }
function HideTop() { var x = document.getElementById("hideDIV"); if (x.style.display === "none") { x.style.display = "block"; } else { x.style.display = "none"; } } </script> </body> </html>
Hope this helps!!
Hi @bricatfree,
Were you able to track the default Klaviyo’s Unsubscribe event within the UnsubDiv form? If yes, please guide me on how to track it. I really appreciate any help you can provide. Dang