Recording clicks on custom button | XM Community
Skip to main content

Hello! I know this has been answered a few times but I am still struggling with recording amount of times a participant has clicked on a custom button I have - in fact I have 10 custom buttons and I want to see which/how many of those buttons were clicked.
Here is my html:









Here is my JS:

Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery("#button1").click(function() {
  jQuery("#infodiv1").toggle();});
jQuery("#button2").click(function() {
  jQuery("#infodiv2").toggle();});
jQuery("#button3").click(function() {
  jQuery("#infodiv3").toggle();});
});

If anyone could assist I would be sincerely grateful!

Create 3 embedded data field in survey flow named "button1_clicks", "button2_clicks", "button3_clicks", and then use following code. Hope that helps :)
Qualtrics.SurveyEngine.addOnReady(function ()
{
    var button1Click = 0, button2Click = 0, button3Click = 0;
    jQuery("#button1").click(function () {
        Qualtrics.SurveyEngine.setEmbeddedData('button1_clicks', ++button1Click);
        jQuery("#infodiv1").toggle();
    });

    jQuery("#button2").click(function () {
        Qualtrics.SurveyEngine.setEmbeddedData('button2_clicks', ++button2Click);
        jQuery("#infodiv2").toggle();
    });

    jQuery("#button3").click(function () {
        Qualtrics.SurveyEngine.setEmbeddedData('button3_clicks', ++button3Click);
        jQuery("#infodiv3").toggle();
    });
});



Thank you so much, ChiragK! This worked perfectly for me. Very grateful for your response!



Leave a Reply