How to use Bootstrap tooltips at a Limesurvey survey

Introduction

Tooltips are a useful feature if you want to add lengthy explanations to certain keywords or answer options at Limesurvey. Since Limesurvey v3.0 the Bootstrap framework is available for all Limesurvey templates which enables you to easily add tooltips to your survey elements. We will show you how this works.

Adding tooltips to Limesurvey survey elements

Bootstrap tooltips need to be added by using proper HTML elements. You can see these elements by switching to the source code view of the Limesurvey editor. We have highlighted default HTML elements:

Limesurvey editor source code mode
Limesurvey editor source code mode

If we now want to use a tooltip for a certain keyword we need to add an additional HTML element. Placing the keyword within a SPAN element is the recommended approach since it shouldn’t change the formatting of the text.
For highlighting the word Limesurvey and adding explanatory text using a tooltip we can use the following HTML:

<span data-toggle="tooltip" title="Limesurvey is the worldwide leading open source survey software">Limesurvey</span>

This is how it looks like at the source code mode of the Limesurvey editor:

Limesurvey tooltip code
Limesurvey tooltip code

And this is how the tooltip shows up when running the Limesurvey survey:

Limesurvey tooltip example
Limesurvey tooltip example

Tooltip core elements

As you can see from the above screenshot it only takes three core elements:

  1. HTML <span>…</span> element for adding the tooltip
  2. data-toggle=”tooltip” for indicating that the element uses a tooltip
  3. title=”Your tooltip text” for defining the to be shown tooltip text

There are some more details your can add to adjust and improve your tooltips:

  • data-html=”true” allows using HTML within the tooltip itself e.g. to highlight certain words within the tooltip with bold text, example:
    title=”Limesurvey is the worldwide <strong>leading</strong> open source survey software”
  • data-placement=”auto | top | bottom | left | right” where auto is the default value. This setting allows defining how the tooltip will be positioned.

Adjusting the tooltip styles

If you have a look at the screenshot above you will notice that the word Limesurvey is not marked in any way to indicate that it uses a tooltip. So users won’t know that additional information is available. To change this, we can add an additional CSS class mytooltip to the above element and then add styles to the custom.css file of the Limesurvey template used to highlight words with tooltips.
This is the extended HTML code for our tooltip:

<span class="mytooltip" data-toggle="tooltip" title="Limesurvey is the worldwide leading open source survey software">Limesurvey</span>

At the custom.css file we are adding the below lines of code to
a) change the cursor on hover
b) underline the word
c) show the keyword as bold text
d) highlight the tooltip keyword with a different color

.mytooltip
{
    cursor: pointer;
    text-decoration: underline;
    font-weight: bold;
    color: orange;
}

This is what we get:

Highlighted Limesurvey tooltip
Highlighted Limesurvey tooltip

Tooltips for Limesurvey answer options

Sometimes you need to explain what a certain answer option means while you try keeping the answer text as short as possible so the answers are still easily readable. Using tooltips you can have short answer options with additional explanations being shown as tooltips. We have created an example for this as well. This is how the answer options are added at a Limesurvey single choice question:

Limesurvey answer options with tooltips
Limesurvey answer options with tooltips

And this is how it looks like at the survey:

Example of answer options with tooltips
Example of answer options with tooltips

You may notice that the tooltip element at the above example is rather small. This is because by default the size is related to the width of the underlying text. In order to increase the tooltip width for list radio or multiple choice questions we can add the following CSS code to our custom.css file:

.tooltipquestion li.radio-item label, 
.tooltipquestion li.checkbox-item label 
{
    width: 100%;
}
.answer-item .tooltip .tooltip-inner 
{
    max-width: 75%;
    margin: auto;
}

As you can see there is now an additional class tooltipquestion. This is needed because we need to overwrite the default styles for the labels of checkbox and radio items. To not apply this to all questions we add the class manually to all questions using tooltips. This can be set at the Display section when editing any Limesurvey question:

Limesurvey display settings
Limesurvey display settings

Lengthy tooltip are now shown like this:

Lengthy Limesurvey tooltips
Lengthy Limesurvey tooltips

Additional information and downloads

Here are some helpful links for you:

How to randomize items at Limesurvey

Limesurvey provides various randomization features at different levels and you should make use of it for various reasons. Especially at market research surveys randomizing items is a must-have feature in order to collect data properly. Another use case is A/B testing where you randomly show version A or B or a question for comparing the outcome of e.g. different question texts.
There are some more reasons we have outlined below when introducing the different Limesurvey randomization features.

Randomizing the order of answers/items

Research shows that people tend to pick one of the first answer options and often do not even check all available options. This can result in misleading survey results. So what can we do?
Well, that is rather simple: Most Limesurvey question types provide a setting Random order which can be found at the Display section below the General options. Simply turn it on and that’s it:

Limesurvey "Random order" setting
Limesurvey “Random order” setting

Want to check how this looks like at a real survey? Then check out the test survey we created for you.

Randomly show 1 of X questions (can be used for A/B testing)

There already is a special blog post dealing with this topic so we will just link to it: https://survey-consulting.com/how-to-randomly-show-1-of-x-questions-at-a-limesurvey-survey/

You can check this randomization feature at this test survey.

For creating an A/B test the approach is the same as explained at the example linked above. Simply created two copies of the same question and set conditions based on the random number to either show question A or question B.

Randomly show questions on page

Besides randomizing items within a question you can also randomize the questions displayed on a single page or within the whole survey.
For setting this up there is an option Randomization group name at the Logic section when editing a question. Enter the same randomization group name at all questions which should show up in random order:

Adding a randomization group name to a question
Adding a randomization group name to a question

So if you added rand1 as randomization group name to questions Q1, Q2 and Q3 these will show up in random order when loading the survey like Q3, Q2, Q1 or Q2, Q1, Q3.

We have provided a sample survey at this link.

Randomly show question groups or survey pages

The group by group display mode is the survey format used at most surveys. This means that you put questions dealing with the same topic into the same question group like questions asking for demographic details. If your survey deals with e.g. tech companies you could then have another set of questions at the follow up question group dealing with question related to Amazon, then have another question group asking details for tech company 1, another one for tech company 2 and so on…

Since the drop off rate would usually lead to receiving many opinions about Amazon but just some very few responses related to the tech companies listed towards the end of the survey, your data will be less reliable when comparing the response details for different companies.
To work around that you could simply show the survey groups related to the different tech companies in random order. This can be achieved by entering the same Randomization group when editing a question group:

Adding a randomization group title
Adding a randomization group title

By adding randomizecompanies to all your to be rated companies these pages will show up in random order within the survey.

We have set up an example with Amazon, Google and Facebook for you showing the question groups for rating these companies in random order.

Randomly show 1 of X follow up surveys

Sometimes users are redirected to a certain follow up survey once they have completed the main survey. In certain cases there is not just one survey but you may want to pick 1 of X surveys randomly and redirect users to them.
This is doable by following the approach of randomly showing a question. You create a question of type equation with code randnumber and as question text you simply add:

{if(is_empty(randnumber.NAOK), rand(1,3), randnumber.NAOK)}

This will create a random number between 1 and 3 if there was no such random number created so far. The newly created number can then be used for defining which URL to call.
You can have another question of type equation using question code redirecturl and based on the random number you can define URLs for 3 different surveys.

{if(randnumber.NAOK == 1, "https://survey.mydomain.com/index.php/111111", 
if(randnumber.NAOK == 2, "https://survey.mydomain.com/index.php/222222", 
https://survey.mydomain.com/index.php/333333"))}

At the survey settings you can optionally enable Automatically call end URL and at the End URL text field of the setting just add {redirecturl.NAOK}. Depending on the randomly created number and the end URL set for it Limesurvey will call one of the 3 surveys randomly.

We added the random redirect to the sample survey created for the Randomly redirect or show 1 of X questionsuse case. Click here to start that survey and you should then see different end URLs at the final “Thank you” page pointing to different surveys.

Sample survey showing all randomization features

All the different features outlined above can be tested at this Limesurvey randomization sample survey.

How to place a certain option at the end of a list with randomized answers at Limesurvey survey

Randomizing answer items is an often used approach at scientific surveys and market research. At Limesurvey this can easily be done. Just go to the advanced question settings of a certain question and then set “Random order” to “Randomize on each page load“.
But often such a list contains an option like “Don’t know” or “None of these” or similar. Such an option may appear in the middle of the list of answers if they are randomized and that looks confusing to the user.

In order to place a certain answer item at the bottom of a randomized list, add the following JavaScript code at your question text, using the source code mode of the editor:

Source code mode:
Source code mode of integrated Limesurvey editor

Code:

<script type='text/javascript'> 
/* Place option 5 at the end of the randomized list */
$(document).ready(function() {
var move_element="5";
/* Please do NOT change the lines below */
var move_element="javatbd{SGQ}"+move_element;
$("#"+move_element).insertAfter("#question{QID} .answers-list .answer-item:last-child");
}); 
</script>

This script snippet will move answer item 5 to the end of the randomized list. “5” is the answer code of the to be moved item.

You want to re-order the “other” option? No problem, we have explained this at How to re-order the “other” option at a Limesurvey survey.

How to remove the “Exit and clear survey” button from a Limesurvey template

While you can easily remove the “Resume later” button from your Limesurvey template by de-activating the “Participant may save and resume later?” feature at “General Settings” -> “Notification & data management” of your survey, removing the “Exit and clear survey” button isn’t possible this way. So what to do?

There are two solutions, both require editing the current template so make sure you have sufficient rights for this. And of course, creating a backup first never hurts 🙂

Using CSS to remove the button

At the Limesurvey template editor select the “template.css” file and at the end add this CSS code to hide the button:

#limesurvey .clearall
{
   display: none;
}

For testing we used the <commercial_mode_on>beautiful Limesurvey template “Janus” which you can download here</commercial_mode_off>. This is how the buttons look like before the above adjustment:

with button

…and with the hidden button the result is:

without button

Removing the button placeholder from template code

The solution we recommend to use is to just remove the button placeholder from the template code. While hiding the button using CSS can cause side-effects and users can still use it when setting the browser to display hidden elements, simply removing the code from the template also does the trick.

To do so go to the Limesurvey template editor and at the “Standard files” section select the “navigator.pstpl” file. That’s where we have placed the related code for all templates from our shop.
You should see the following code at which you can simply remove the {CLEARALL} placeholder:

<div id="navigator" class="clearfix">
   <div id="left">
      {SAVE}
   </div>
   <div id="right">
      {CLEARALL}
   </div>
   <div id="middle">
      {NAVIGATOR}
   </div>
</div>

Alternatively, you can comment out the placeholder so that the related code line reads:

<!-- {CLEARALL} -->

If the above doesn’t work for you and you need further help with adjusting your Limesurvey template just drop us a note.

How to calculate the number of days between a date inputted by the user and the current date

Sometimes you want to find out how many days or years have passed between today’s date and a date inputted by the user at a Limesurvey survey. The process is a little complex but it can be done using the Limesurvey Expression Manager.

Calculating the number of days

Let’s assume there is a question of type “date” at your survey which uses question code “q2”. The user can select any date using the date picker and at the help text you can show a message like “That was X days ago.”.
To calculate the value for X you can use this expression:

{floor((time() - strtotime(q2)) / (60 * 60 * 24))}

This looks a little complex, so let’s have a look at the details:

  • To get the current time stamp we use time().
  • Using the strtotime() Expression Manager function we create a time stamp based on the date inputted by the user at question “q2”: strtotime(q2)
  • That time stamp gets subtracted from the current time: (time() – strtotime(q2))
  • Since we are not interested in the time difference in seconds but want to know about the exact number of days we divide the result by (60 * 60 * 24) because one day has 24 hours with 60 minutes and 60 seconds.
  • Finally, the result is rounded down using the floor() function.

Calculating the number of years

Similar to the above approach you can also calculate the number of years between a certain date inputted by the user and today’s date. The expression for this is:
{floor((time() - strtotime(q2)) / (60 * 60 * 24 * 365))}

Using calculated result within conditions/relevance equations

You can not only use this expression to output the results of the calculation within any (follow up) question but you can also use this code for conditions by entering it at the “relevance equation” field (without “{” and “}”). E.g. you can ask participants for their day of birth and then calculate if they are already 18 years old. If not, you can use conditions to hide certain follow up questions or show them a warning.

Storing calculated result

If you want to store the calculated result all you need to do as adding the expression (with “{” and “}”) at an equation question. You can even hide that question (edit question -> advanced question settings -> “Always hide this question”) and the result will still be stored at the database.

Creating a fully responsive Limesurvey Template

We could probably write 10-12 pages about how to create a fully responsive Limesurvey template but we want to spare you from reading about all the technical details. Instead, we just want to sum up our findings and present you the results.

Several people have spent dozens of hours to create the first fully responsive Limesurvey template. You can test the template at this test survey and buy the “TFR Responsive” Limesurvey template at the Limesurvey Template Shop.

Benefits of using a responsive Limesurvey template

Of course, the biggest benefit of a fully responsive Limesurvey template is easily serving lots of different devices and presenting the survey questions well displayed on each of them. This does not only make your survey look more professional it will also lead to an increased response rate.
Furthermore, a known disadvantage of common Limesurvey templates is the lack of support for touch screen devices such as smartphones and tablets. Using such a device it can be really tricky to click a radio button or tick the small check boxes. Participants being frustrated because of such a badly designed user interface may just close the survey and leave. When using our fully responsive Limesurvey template participants can just click the text of an answer option at single or multiple choice question to mark an item. At array questions we made the whole cell clickable so even on small devices it is really easy to answer the survey questions. In addition to that the display of larger array questions is optimized by using responsive tables which means that a large table gets split up into several smaller ones which display nicely on small screens.

Technical details

The template we created is based on the bootstrap framework which is famous for serving different devices nicely. For supporting high quality images we make use of Retina JS which supports dynamic switching to a high quality version of an image or logo file if a retina display is used by the participant.
A known issue when using small devices is displaying large array questions nicely. We implemented the “No more tables” JavaScript library at our responsive Limesurvey Template which dynamically splits up large Limesurvey array questions into smaller sections which display fine even on very small devices.
Furthermore, we added custom icons and “Open Sans” as a modern font to achieve a pleasant look and feel so that our template doesn’t look as boring as the shipped Limesurvey templates.

Additional information/links

Sounds interesting? -> Check this test survey.

Want to use this fully responsive Limesurvey template? -> Get the “TFR Responsive” Limesurvey template at the Limesurvey Template Shop.

Want to see more high quality screenshots? -> There you go:

Survey design tips & tricks

Designing your own survey is pretty easy when using Limesurvey. Unfortunately, creating a really bad survey is also pretty easy. That’s why we have set up a list of survey design tips & tricks. Based on our experience with more then 100 survey projects per year the following recommendations hopefully help you designing better surveys.

Motivate users to raise the completion rate

A user being presented with a simple “Please help me by filling out the survey, it will take 10-15 minutes.” will see no benefit in wasting his/her time with this. In such cases an incentive like “All users which fill out the survey completely will be allowed to take part in a lottery and can win one of 5 Amazon vouchers worth 20,00€.” can raise participation and completion rates significantly.

Start with simple questions

A survey should never start with complex questions people have problems answering at all. Instead, place very simple questions like demographic questions at the beginning. Everyone can answer those and they present an easy introduction. Once people have started filling in simple data they tend to finish their work and not closing a survey early.

Questions should be clear

This may sound pretty obvious but for every question make sure it is clear and precise, collectively allowing for detailed, unambiguous and meaningful answers.

Add screening questions to the start

Nothing is more annoying than having completed several questions asking for complex information and being told later that for certain reasons like your age or gender you were suddenly screened out and are not allowed to complete the survey and maybe receive a certain incentive.

If users need to agree to certain terms and conditions or have to be of a certain age or gender you should always place such screen out questions at the beginning.

Add problematic questions to the end

Similar to placing easy questions at the beginning you should place problematic questions (e.g. about illnesses) at the end. People having already completed 80% of your survey will most likely answer such questions as well.

The fewer questions the better

People tend to ask this and that instead of focusing on the really important questions only. Always make sure a certain question is really important. The fewer questions the higher the completion rate!

Use free text questions to ask for additional information

Open questions may reveal unexpected and very worthy additional information. You should add optional text questions at all important parts of the survey, asking users “Is there anything else you want to tell us about XYZ?”. This may lead to important user feedback you would not have received when using closed questions only.

Make sure your questions are non-suggestive

Asking users “What is your opinion about XYZ?” uses neutral speech while a question like “Don’t you agree that LimeSurvey is a really great tool?” is a very suggestive question which will cause users to give more positive feedback.

Only make the most important questions mandatory

Having to complete a survey at which each question is mandatory can be really painful, especially when it comes to complex matrix questions.

When designing a survey you always need to ask yourself “Is this question important enough to make it mandatory?”. Only the questions related to data you really need should be mandatory.

Keep questions and answers short and easily readable

Nothing to add to this…

Note: There is a second blog post “Survey design tips & tricks – Part 2“.

 

BTW, if you are not very familiar with designing surveys but need to create an important one, we can help with that. Our experience can help you at creating a great survey with a high completion rate.
Just drop us a note if we should review your survey or set it up for you.