Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1
  • 2

THEMA: collecting browser information

collecting browser information 1 Jahr 8 Monate her #84094

  • pomaikai
  • pomaikais Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 5
  • Karma: 0
It is possible for limesurvey to collect browser version and screen resolution and media device ie pc, tablet etc automatically from participants.

I though I could issue a url with id and pass to google analytics and somehow merge the data at a later stage, but does anyone know of an easier way.

cheers

tom
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: collecting browser information 1 Jahr 8 Monate her #84097

  • Ben_V
  • Ben_Vs Avatar
  • OFFLINE
  • Platinum Lime
  • Beiträge: 933
  • Dank erhalten: 193
  • Karma: 62
Hi,
you can try to use this following code in the source of a long free text question (adapted from another code I've found few weeks ago in the forum and working well with my installation)

You just have to adapt the var IDs (see 3 first lines) with yours...
(the last line will hide the question)

<script type="text/javascript">
var SID = '123';  // survey ID
var GID = '456';    // group ID
var QID = '789';  //  question ID
 
var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browserName  = navigator.appName;
var fullVersion  = ''+parseFloat(navigator.appVersion); 
var majorVersion = parseInt(navigator.appVersion,10);
var nameOffset,verOffset,ix;
 
// In Opera, the true version is after "Opera" or after "Version"
if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
 browserName = "Opera";
 fullVersion = nAgt.substring(verOffset+6);
 if ((verOffset=nAgt.indexOf("Version"))!=-1) 
   fullVersion = nAgt.substring(verOffset+8);
}
// In MSIE, the true version is after "MSIE" in userAgent
else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
 browserName = "Microsoft Internet Explorer";
 fullVersion = nAgt.substring(verOffset+5);
}
// In Chrome, the true version is after "Chrome" 
else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
 browserName = "Chrome";
 fullVersion = nAgt.substring(verOffset+7);
}
// In Safari, the true version is after "Safari" or after "Version" 
else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
 browserName = "Safari";
 fullVersion = nAgt.substring(verOffset+7);
 if ((verOffset=nAgt.indexOf("Version"))!=-1) 
   fullVersion = nAgt.substring(verOffset+8);
}
// In Firefox, the true version is after "Firefox" 
else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
 browserName = "Firefox";
 fullVersion = nAgt.substring(verOffset+8);
}
// In most other browsers, "name/version" is at the end of userAgent 
else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < 
          (verOffset=nAgt.lastIndexOf('/')) ) 
{
 browserName = nAgt.substring(nameOffset,verOffset);
 fullVersion = nAgt.substring(verOffset+1);
 if (browserName.toLowerCase()==browserName.toUpperCase()) {
  browserName = navigator.appName;
 }
}
// trim the fullVersion string at semicolon/space if present
if ((ix=fullVersion.indexOf(";"))!=-1)
   fullVersion=fullVersion.substring(0,ix);
if ((ix=fullVersion.indexOf(" "))!=-1)
   fullVersion=fullVersion.substring(0,ix);
 
majorVersion = parseInt(''+fullVersion,10);
if (isNaN(majorVersion)) {
 fullVersion  = ''+parseFloat(navigator.appVersion); 
 majorVersion = parseInt(navigator.appVersion,10);
}
 
$(document).ready(function() {
  $('#answer'+SID+'X'+GID+'X'+QID).val(''
+'Browser name = '+browserName+'<br>'
+'Full version = '+fullVersion+'<br>'
+'Major version = '+majorVersion+'<br>'
+'navigator.appName = '+navigator.appName+'\n'
+'navigator.userAgent = '+navigator.userAgent); 
 
// hiding the question 
$('#question'+QID).hide();
 
});
</script>
Ben/

Remember that if you want to use javascript within Limesurvey you have to disable a security filter before you can add your javascript in source code mode. =>Go to global settings and set the setting 'XSS-Filter' to 'off'.
Benoît

goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche)
goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar)
goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de...
Letzte Änderung: 1 Jahr 8 Monate her von Ben_V.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: collecting browser information 1 Jahr 8 Monate her #84099

  • holch
  • holchs Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 2446
  • Dank erhalten: 254
  • Karma: 94
Google Analytics data is usually agregated. I am not an expert, but in my opinion you should not be able connect they survey data with the GA data.

However, Google is getting this information via Javascript, so you should be able to create a script reading this and then write it into hidden questions.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: collecting browser information 1 Jahr 8 Monate her #84101

  • holch
  • holchs Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 2446
  • Dank erhalten: 254
  • Karma: 94
Benitovs answer works for me as well. Now you just need to find a way to access the information about resolution (or is it the viewport you want to know?) and the media type.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: collecting browser information 1 Jahr 8 Monate her #84105

  • Ben_V
  • Ben_Vs Avatar
  • OFFLINE
  • Platinum Lime
  • Beiträge: 933
  • Dank erhalten: 193
  • Karma: 62
for screen size maybe you can use a 2nd hidden question... for example button radio list, prechecked via javascript...
using some code like this (not tested, it's just an idea ...) ;)
<script type="text/javascript" charset="utf-8"> 
	var SID = '012';  // survey ID
	var GID = '345';    // group ID
	var QID = '678';  //  question ID
 
	$(document).ready(function() {
		if (screen.width==800||screen.height==600) //if 800x600
		{$('#answer'+SID+'X'+GID+'X'+QID+'A1').attr('checked', true);}
 
 
		else if (screen.width==640||screen.height==480) //if 640x480
		{$('#answer'+SID+'X'+GID+'X'+QID+'A2').attr('checked', true);}
 
 
		else if (screen.width==1024||screen.height==768) //if 1024x768
		{$('#answer'+SID+'X'+GID+'X'+QID+'A3').attr('checked', true);}
 
		else //if all else
		{$('#answer'+SID+'X'+GID+'X'+QID+'A0').attr('checked', true);}
 
	// document.limesurvey.submit();
	});
 
</script>

Note A0, A1, A2... are the codes for your answer options.
Benoît.
Benoît

goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche)
goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar)
goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de...
Letzte Änderung: 1 Jahr 8 Monate her von Ben_V.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: pomaikai

Re: collecting browser information 1 Jahr 8 Monate her #84107

  • holch
  • holchs Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 2446
  • Dank erhalten: 254
  • Karma: 94
@Benitov: I wouldn't create a closed question. I would write the screen resolution directly into the same text field. Because today the list of screen resolutions can be quite ample, with more and more mobile devices (smartphones, tablets) on the market.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: pomaikai

Re: collecting browser information 1 Jahr 8 Monate her #84109

  • pomaikai
  • pomaikais Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 5
  • Karma: 0
Thank you all so much for your input.

I want to try to gain as much information about the device being used by the respondents similar if you like to the spec here www.w3.org/TR/2012/REC-css3-mediaqueries-20120619/

@Benitov: thank you for the code.
@holch: you have 'hit the nail on the head' as it were. I am putting together a research project looking at web site design and its relationship with browsing behaviour on a commerce site based on different devices because as you say mobile and tablets are more and more important.

If it is possible to collect details of the device etc automatically it will save a lot of bother later on.

I now appreciate that javascript within a question would appear to be the way to go. I had not considered that, nor can I write it, but I am familiar with other basic code so will have a play.


Thanks again

Tom
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: collecting browser information 1 Jahr 8 Monate her #84111

  • holch
  • holchs Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 2446
  • Dank erhalten: 254
  • Karma: 94
So you might want not only the screen width, but also the view port. But this is all accessible with JavaScript.

Here maybe also an approach to find out the device:

www.abeautifulsite.net/blog/2011/11/dete...ces-with-javascript/
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: Ben_V

Re: collecting browser information 1 Jahr 8 Monate her #84122

  • Ben_V
  • Ben_Vs Avatar
  • OFFLINE
  • Platinum Lime
  • Beiträge: 933
  • Dank erhalten: 193
  • Karma: 62
now appreciate that javascript within a question would appear to be the way to go. I had not considered that, nor can I write it, but I am familiar with other basic code so will have a play.

So ... in the same serie the following code can be a good base to gather the browser window size !
<script type="text/javascript">
 
var SID = '123';
var GID = '456';
var QID = '789'; 
 
jQuery(document).ready(function() {
 
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  }
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  }
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
 
   $('#answer'+SID+'X'+GID+'X'+QID).val(myWidth +' X '+ myHeight); 
 
 
});
</script>

Ben/
Benoît

goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche)
goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar)
goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de...
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: collecting browser information 1 Jahr 8 Monate her #84169

  • pomaikai
  • pomaikais Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 5
  • Karma: 0
I can get the scripts to work however, I can only get them working depending on certain settings.

Scripts work when the survey is set formatted to be 'question by question' but not 'all in one'. I can get them to work 'group by group' as long as there is not more than one script in each group.

I have searched as best I can the forums and the work arounds to no avail.

I assuming at this stage that when loading the scripts are conflicting / affecting each other, but I am unsure how to isolate them so that they don't. When loading 'all in one' it is always the last script that essentially works.

Do you know if this is a limitation of Limesurvey or I am doing something obviously wrong.

Limesurvey Version 1.92+ Build 120725

Tom
Letzte Änderung: 1 Jahr 8 Monate her von pomaikai. Begründung: typos
Der Administrator hat öffentliche Schreibrechte deaktiviert.
  • Seite:
  • 1
  • 2
Moderatoren: ITEd
Ladezeit der Seite: 0.176 Sekunden
Donation Image