The LimeSurvey Fund-Raiser 2012 is complete. Thank you for donating a total of 25,000 USD!     List of donors »

Bienvenido, Invitado
Nombre de Usuario: Contraseña: Recordarme
  • Página:
  • 1

TEMA: Adding Google Analytics

Adding Google Analytics hace 2 años 1 mes #58619

  • medicnick
  • Avatar de medicnick
  • DESCONECTADO
  • Junior Lime
  • Mensajes: 20
  • Karma: 0
It was not too difficult to add Google Analytics. It requires two steps.
1) Create a file named analyticstracking.php and save it in the root directory with this content replacing the UA=xxxxxxx-x with your own tracking code:
<script type="text/javascript">
 
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxx-x']);
  _gaq.push(['_trackPageview']);
 
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
 
</script>
2) Add this line near the top of your index.php file "require_once(dirname(__FILE__).'/analyticstracking.php');"

This is working for me but be forewarned that due to the require_once that if it cannot find the file, it may return a page error. There may be another way to code that to request_once or something similar but I don't know the optimal language here.

Cheers,
Nick
El administrador ha desactivado la escritura pública.

Re: Adding Google Analytics hace 2 años 1 mes #58686

  • DenisChenu
  • Avatar de DenisChenu
  • DESCONECTADO
  • Moderator Lime
  • Mensajes: 4403
  • Gracias recibidas 455
  • Karma: 166
Hello,

Why don't put ui tracking directly in template ?

I think the best is to put the script at welcome.pstpl (first page for each survey) and in surveylist.pstpl (index page, without survey).

:)
El administrador ha desactivado la escritura pública.

Re: Adding Google Analytics hace 1 año 9 meses #64849

  • Nickko
  • Avatar de Nickko
  • CONECTADO
  • LimeSurvey Team
  • Mensajes: 1493
  • Gracias recibidas 127
  • Karma: 34
I'm looking for the same think, thank's Shnoulle.

Edit : I go to inserte GA code in endpag.pstpl
Nickko
Ergonome / Usability expert
Última Edición: hace 1 año 9 meses por Nickko.
El administrador ha desactivado la escritura pública.
  • Página:
  • 1
Moderadores: DenisChenu, ITEd
Tiempo de carga de la página: 0.259 segundos
Donation Image