Guide Tip: New way to request feedback for article downvotes | The place for Zendesk users to come together and share
Skip to main content
Edward13
December 12, 2023

Guide Tip: New way to request feedback for article downvotes

  • December 12, 2023
  • 22 replies
  • 130 views

Prerequisite:
* Admin access Support & Guide
* Default Copenhagen Theme
* Turn-on anonymous ticket submission
* Custom form
* Custom fields editable by end users


Steps:
1. Go to article_page.hbs
2. Paste html code (a) in line 162
3. Paste script code (b) at the bottom
4. Go to style.css (c) then add css code at the bottom
5. Publish the changes and test your new theme in Incognito mode

 

a. HTML - replace subdomain, change the options, values, and spiels as needed

{{!-- Article Feedback --}}
    <form class="request-form hide" id="article-vote-down-form">
        <label for="reason">Sorry about that! What was the issue?</label>
        <input type="hidden" value="Article feedback: {{article.title}}" class="hide" name="subject">
      <input type="hidden" value="https://subdomain.zendesk.com/{{help_center.url}}/articles/{{article.id}}" name="url">
        
        <select class="custom-form-field" id="reason" name="reason" required>
            <option value="" disabled selected>-- Please choose an option --</option>
            <option value="incorrect_information">Incorrect or missing information</option>
            <option value="unclear_content">Hard to understand</option>
            <option value="typos_broken_links">There are typos or broken links</option>
            <option value="resources_issue">Issues with images, GIFs, or videos</option>
            <option value="feature_feedback">I wish the feature worked a different way</option>
            <option value="general">Something else</option>
        </select>
        
        <textarea name="description" placeholder="Tell us more" required></textarea>
        <button type="submit" class="button feedback-button">Submit article feedback</button>
            </form>

<div id="feedback-success" class="hide">
    <p>We use your article feedback to improve our help content—thank you!</p>
</div>

 

 

b. JS - make sure to change ticket_form_ID and custom_fields: [

<script>
document.onreadystatechange = () => {
  if (document.readyState === "complete") {
    const voteButtonUp = document.querySelector(".article-vote-up");
    const voteButtonDown = document.querySelector(".article-vote-down");
    const successMessage = document.querySelector("#feedback-success");
    const voteDownForm = document.querySelector("#article-vote-down-form");

    function hideForm() {
      voteDownForm.classList.add("hide");
    }

    function showForm() {
      voteDownForm.classList.remove("hide");
    }

    hideForm();

    async function submitRequest(e) {
      const formData = new FormData(e.target);
      const form = Object.fromEntries(formData);
      const reason = form.reason || "";

      let body = {
        request: {
          subject: form.subject,
          comment: { body: form.description },
          custom_fields: [
          { id: 12386706806425, value: form.url }, //article URL, replace ID with your custom field
          { id: 900005760523, value: reason }, //feedback reason, replace ID with your custom field
          ],
          ticket_form_id: 900000044103, //your article feedback form, replace with your custom form ID
        },
      };

      let headers = new Headers();
      headers.append("Content-Type", "application/json");
      headers.append("Accept", "application/json");

      body.request.requester = { name: "Anonymous" }; //you can replace the name of the requester if need (e.g Help Center Feedback)

      await fetch("/hc/api/internal/csrf_token.json")
        .then((data) => data.json())
        .then((res) => {
          headers.append("X-CSRF-Token", res.current_session.csrf_token);
          headers.append("X-REQUESTED-WITH", "XMLHttpRequest");
        });

      await fetch("/api/v2/requests", {
        method: "POST",
        headers: headers,
        body: JSON.stringify(body),
      }).then((res) => {
        if (res.status == 201) {
          hideForm();
          successMessage.classList.remove("hide");
        } else {
          console.log("Error submitting request");
        }
      });
    }

    voteDownForm.addEventListener("submit", (e) => {
      e.preventDefault();
      submitRequest(e);
      return false;
    });

    if (voteButtonUp) {
      voteButtonUp.addEventListener("click", function (event) {
        event.preventDefault();
        successMessage.classList.remove("hide");
        hideForm();
      });
    }

    if (voteButtonDown) {
      voteButtonDown.addEventListener("click", function (event) {
        event.preventDefault();
        successMessage.classList.add("hide");
        showForm();
      });
    }
  }
};
</script>

 

c. CSS - no action needed, but you can design if needed

/***** Article Feedback *****/
.hide {
  display: none;
}

select.custom-form-field,
textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
}


Snippets:


22 replies

Edward13
Edward13Author
May 8, 2024

Hello @papaefthymiou ,  you will have to create a custom report and dashboard in Explore to see the comments and votes.

papaefthymiou
July 17, 2024

@paolo14, regarding your comment above about custom forms, when we created a form for help center feedback, this appeared as a dropdown option on our new request page for users to choose when contacting support. We don't want that, we only need this appearing when people click the thumbs down icon in articles. Is there a way to go around this? Thank you!

 

Richard11
January 29, 2025

I've added this to our KB for signed in users if anyone is still looking to do it. It's explained here how you need to fetch the user token and send along with the request

 

https://developer.zendesk.com/documentation/help_center/help-center-api/secured-requests/#making-zendesk-api-requests-with-csrf-tokens

Edward13
Edward13Author
January 29, 2025

Hey @richard11 - Thanks for the save! We're u able to make it work for users using SSO (e.g. Google)?

Richard11
January 30, 2025

Yes @edward13 we only use Google SSO so that is all I've tested with. We wanted logged in users to be able send feedback anonymously.

This is the important bit right

 

  fetch("/api/v2/users/me.json")
       .then(response => response.json())
       .then(data => {
         const csrfToken = data.user.authenticity_token;
         
         // Send feedback as a new Zendesk request (ticket)
         fetch("https://[subdomain].zendesk.com/api/v2/requests.json", {
           method: "POST",
           headers: {
             "X-CSRF-Token": csrfToken,
             "Content-Type": "application/json"
           },
           body: JSON.stringify({
             request: {
               subject: "Article Feedback",
               comment: { 
                 body: `Feedback for the article: ${articleUrl}\n\nComment:\n${comment}`,
               },
               requester: { name: "Anonymous User" }
             }
           })
         })
Aleksandra12
March 21, 2025

Hello! @edward13 Thanks a lot for your code, it helped us a lot. I just have a problem, and I wanted to ask maybe you could help. 
The thing is that the reason value is shown as ‘null’, so the reason for the downvote doesn't appear in the feedback ticket (the second screenshot is taken from yours for comparison).  What can be a potential cause of the issue? 
Thank you in advance!

Edward13
Edward13Author
March 22, 2025

Hello @aleksandra12 , this looks like a drop-down field value related. Try to mirror the values of the field from the HTML to the value you have set on Zendesk Admin Field. In my case below they are the option values.

     <select class="custom-form-field" id="reason" name="reason" required>
           <option value="" disabled selected>-- Please choose an option --</option>
           <option value="incorrect_information">Incorrect or missing information</option>
           <option value="unclear_content">Hard to understand</option>
           <option value="typos_broken_links">There are typos or broken links</option>
           <option value="resources_issue">Issues with images, GIFs, or videos</option>
           <option value="feature_feedback">I wish the feature worked a different way</option>
           <option value="general">Something else</option>
       </select>
       

Aleksandra12
March 25, 2025

Thank you, that worked!

June 12, 2025

How do I capture the Feedback Option the client selected in my ticket/form?
 

June 12, 2025

@edward14 Can you help me with this section? How do I get these options to prefil into the ticket form?
When an article is downvoted, the user is asked to submit feedback, a new ticket is created but it only contains the additional information they typed in. 
I want to also capture the option they selected in the list in my ticket form.

Thank you!



  <select class="custom-form-field" id="reason" name="reason" required>
           <option value="" disabled selected>-- Please choose an option --</option>
           <option value="incorrect_information">Incorrect or missing information</option>
           <option value="unclear_content">Hard to understand</option>
           <option value="typos_broken_links">There are typos or broken links</option>
           <option value="resources_issue">Issues with images, GIFs, or videos</option>
           <option value="feature_feedback">I wish the feature worked a different way</option>
           <option value="general">Something else</option>
       </select>