Forum Discussion

fuenteso's avatar
fuenteso
Leader
8 years ago

Triggering a survey when a user accepts a solution

Hi,

 

We're looking for a way to survey our customers once they accepted a solution on our community. The goal is to survey only the user that accepted the solution, right after clicking the button.

 

I'm considering two options here:

- Our survey service can trigger a survey when a certain keyword is on the URL. I noticed that when a user accepts a solution, the form is submitted and the page is refreshed. I'm looking for a way to add that extra parameter to the URL when the page is refreshed. Unfortunately, that's a part of the community I don't have access as a user.

- Add a pop up with a button to launch the survey when the user clicks 'Accept as solution', but again, the page is refreshed and I'm not sure how the whole process work on the back end.

 

Do you have any tips or ideas?

 

Thanks!

  • fuenteso

     

    <div class="InfoMessage lia-panel-feedback-inline-safe">
    	<div class="lia-text">
    		<p ng-non-bindable="" tabindex="0" role="action-succeed">Success!  This post is now an accepted solution.</p>
    	</div>
    </div>

    After page refreshes, you will see this success message. Simply use Lithium.jQuery to find the $('.lia-panel-feedback-inline-safe [role="action-succeed"]')   and test if the text match "Success!  This post is now an accepted solution.". Do not hard code this text, but use ${text.format("xxx")?js_string}

    If it passes the test, then you can trigger the survey.

     

    If it helps, a kudo :)

     

4 Replies

  • fuenteso - 

    Due to OOTB functionality, these two option will not work for you which you have already mentioned.  In this case,

    the best option would be opening a new tab while clicking on "Accept as solution" button.  You can open any custom page in new tab for the survey and can pass extra parameters. 

     

    The alternative option for this would be creating a custom Accept as solution button. This option would be helpful if you want to open a popup by clicking on Accept as solution button. 

    Here is restapi call to mark a reply as solution https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=commv1&leaf-id=Message.solutions.solution.mark#Message.solutions.solution.mark

     

  • fuenteso

     

    <div class="InfoMessage lia-panel-feedback-inline-safe">
    	<div class="lia-text">
    		<p ng-non-bindable="" tabindex="0" role="action-succeed">Success!  This post is now an accepted solution.</p>
    	</div>
    </div>

    After page refreshes, you will see this success message. Simply use Lithium.jQuery to find the $('.lia-panel-feedback-inline-safe [role="action-succeed"]')   and test if the text match "Success!  This post is now an accepted solution.". Do not hard code this text, but use ${text.format("xxx")?js_string}

    If it passes the test, then you can trigger the survey.

     

    If it helps, a kudo :)

     

  • Or you could bind a javascript click handler to the "Accept as a solution"-Button that creates a custom cookie when the button is clicked, then you could check for that cookie on any subsequent page and display the survey in an overlay/modal window if that cookie is present (do not forget to remove it when the survey is answered or let it expire in an appropriate amount of time to not annoy the users!).

  • fuenteso's avatar
    fuenteso
    Leader
    8 years ago

    That's an interesting approach. I didn't want anything too elaborated because this will be a pilot test, so checking for the message sounds like a good idea.

     

    Thanks peterlu!