We are making a new support center website for our company. We want to create a “Was this article Helpful?” section with buttons (yes and no). How can we do this (like what Google does)?
Thanks,
Pax Aurora Teams
We are making a new support center website for our company. We want to create a “Was this article Helpful?” section with buttons (yes and no). How can we do this (like what Google does)?
Thanks,
Pax Aurora Teams
Okay, assuming you know a little coding. When a button is clicked the simple method is to update a field in the collection for the article. This can be a true/false, but the rating would be only as good as the last person clicking the button.
The next way is have a field in the collection that holds a score. A Yes (+1) and No (-1). This field is a counter starting at 0 in the article collection. You can assume any score > 0 is helpful, so 3 yes clicks + 1 no click = 2, so your code would rate the article as positive and display a happy face if that value is > 0. Now you have a score, it is easy to sort by the most helpful articles, etc.
You’d need two buttons with code attached and a numeric field in your article’s collection.
Good luck
Hi there …
You should have one or two fields dedicated to this in your DB, I recommend using only one object field to store all the positive and negative votes.
const feedback = {
positive: [],
negative: []
}
When someone clicks to vote (up), you should add his ID to the positive array, and subtract it from the negative array if it does exist.
I’m using the same method on my website here.
Hope this helps~!
Ahmad
@Kyle as @ahmadnasriya said you need to keep track of the id of each user otherwise one user could down vote an article multiple time.
@paxaurora6 I would rather use a collection Feedback (_id, memberId, articleId, vote) where vote is a number (+1 or -1). then you can use Sum to compute the score of a given article. You can also use the couple memberId-articleId to be sure each article is voted once per user
I have a few questions: 1: Should I make a new database for the votes? 2: Do I add an array field in the DB or an object? 3: Do I name the buttons a name to correspond with the DB? 4: Is there more code to this than the code given and do I add something to the fields?
Sorry for these questions. I’m not good with code.
@plomteuxquentin Yup, I agree that it could be down voted multiple times. Just threw something up there :-). @ahmadnasriya and your solutions are definitely much more robust, although both seem to rely on members having logged in.
I’ve thinking around this sort of thing (nothing else to do in lockdown) and I’m probably digressing and going off on a tangent. What does “Was this article helpful” mean and what do the measurements actually demonstrate? Let me give you a real dumb example - a user searches for “food” and an article on cat food comes up. The user in their head wanted something on dog food so the article did not help. Whilst the article on cat food was well written, the user clicks it was not helpful and therefore down plays it. Perhaps a “Was this article relevant?” would be better as a lot can come down to how the article is presented in the knowledge base. Try also if search based, logging the words/terms that surfaced the article. Then you get people like me who never click these buttons and throw off the scores. When an article is surfaced, how are these non-clicks scored? Maybe the article is initially scored with a neutral score. Either way, I think non-clicked articles need to take some place in the scoring. How’s that for completely overthinking something?
Another after thought is that when the no button is clicked, then show an input box for a reason. Not sure who would fill it in… but just another thought I’ll blame on lockdown.
You can have a dedicated DB for this purpose, but I wouldn’t do that since it’s not necessary, instead, on the articles DB itself.
I would create an " Object " field and give its ID a name of “feedback” or “rating”, whatever you want to call it.
The IDs of your elements don’t matter for the voting process, you can use images, texts, or even boxes to trigger the voting, as long as the UI clearly tells which is which.
Yes there’s, you need to have event handlers that should invoke the voting function, also, it’s highly recommended that you have your function on the backend for security reasons.
The arrays should be used to store/check if the user already voted or not, and maintaining the feedback section in general, if the section you want to collect votes on is crucial, you should strict it to only logged members, but if it’s not, you can use the logged out user ID to maintain the voting on the same session, also, the ID remains the same for the local logged in user, so even if the user closed the website and tried to vote again after a refresh, its ID might be used, but don’t quote me on that as I’m not sure.
@kylejsoutham non logged in users have IDs as well, their IDs remains the same for a period of time on the same browser - don’t quote me on that please, so technically, you could use it to maintain the voting.