A new plugin: Piwik for Limesurvey -- your comments appreciated.

More
3 years 3 months ago #116615 by SteveCohen
SteveCohen created the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.
Hi all,
This is my first post and development contribution. Hopefully the first of a few ideas I have!

I've developed a plugin to inject Piwik tracking code into the DOM. I've put the code on github at https://github.com/SteveCohen/Piwik-for-Limesurvey .

Comments very welcome --desired, actually, becuase I've mostly hacked this together using other plugins as examples... :unsure:

There've been a few requests for this over the years, and this might just help out with the open feature request )... or at least avoid the workarounds requiring users to edit pstl files.

Thanks,

Steve.
The following user(s) said Thank You: Ben_V, gantier

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #116629 by Mazi
Mazi replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.
Thanks for sharing your solution. Can you share a screenshot of the plugin settings?


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #116646 by SteveCohen
SteveCohen replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.
Sure; see attached. Pretty simple for the moment. "What should i put here?" is a link to the Piwik docs.
Attachments:

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #116648 by SteveCohen
SteveCohen replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.
Mods, would you move this to the 'plugins' forum? My apologies for posting in the wrong place.

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #116649 by Mazi
Mazi replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.

SteveCohen wrote: Mods, would you move this to the 'plugins' forum? My apologies for posting in the wrong place.

Topic moved.

Thanks for sharing a screenshot. Just a short question: Does piwik track all surveys or would it be possible to enable tracking for certain surveys only like we do with the Google Analytics feature of Limesurvey?


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #116691 by SteveCohen
SteveCohen replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.

Mazi wrote: Just a short question: Does piwik track all surveys or would it be possible to enable tracking for certain surveys only like we do with the Google Analytics feature of Limesurvey?

That's a limitation at the moment :). Currently the plugin will make Piwik track every survey, but disabling on a per-survey basis is on the roadmap. I'll try to get that done in the next week or so.

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago - 3 years 3 months ago #116854 by SteveCohen
SteveCohen replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.
How do you get per-survey settings in a beforeSurveyPage event? I've tried for a few days now and aren't making much progress, so I'll just ask!

I've managed to save it to the lime_plugin_settings table using this code, which allows admins to turn per-survey tracking on and off:
        public function beforeSurveySettings()
        {
            $event = $this->getEvent();
            $event->set("surveysettings.{$this->id}", array(
                'name' => get_class($this),
                'settings' => array(
                    'piwik_trackThisSurvey' => array(
                        'type' => 'select',
                        'options'=>array(0=>'No',
                            1=>'Yes'),
                        'default'=>$this->get('piwik_trackSurveyPages', null, null, false), //Default is whatever is set by the superadmin.
                        'label' => 'Collect web analytics data from respondents',
                        'current' => $this->get('piwik_trackThisSurvey', 'Survey', $event->get('survey'))
                    )
                )
            ));
        }

...How do I get the stored value back? i.e. within a beforeSurveyPage event, how do I query the current value of 'piwik_trackThisSurvey' for the survey that is currently being viewed?

I've tried various methods from other plugins but I only ever get NULL's back. I have confirmed the settings are being saved in the lime_plugin_settings table.

Any hints?
Last Edit: 3 years 3 months ago by SteveCohen.

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #116861 by DenisChenu
DenisChenu replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.
Thanks.

For public survey, i make a fork and pull.
But the problem is to have the "actual" page of the survey in beforeSurveyPage :). I think we need to get the actual page only in JS ;).

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago - 3 years 3 months ago #116894 by SteveCohen
SteveCohen replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.
Thanks for your reply, Denis. :)

So the SurveyID isn't available in PHP using beforeSurveyPage?? Or am I misunderstanding?

If it's not available, I guess I could use AJAX to load the code. Something like:
  1. beforeSurveyPage adds adds JS script to make an AJAX request to a php script. This request includes the surveyID.
  2. The php file determines whehter the tracking code should be loaded, for example, returning true or false (Problem: what would the URL to this script be??)
  3. Once AJAX is done, if the result was true, add the tracking code.
  4. .
..Yuck! ;)

In the meantime, I've put my current code up ( https://github.com/SteveCohen/Piwik-for-Limesurvey ). This has placeholder code for the disable-per-survey feature.
Last Edit: 3 years 3 months ago by SteveCohen. Reason: Didn't need to include Denis' entire message in quote :)

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #116903 by DenisChenu
DenisChenu replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.
No,

surveyid are in the input : manual.limesurvey.org/BeforeSurveyPage
The surveyId is OK with beforeSurveyPage only. I think more for "welcome page", "thanks page", register page etc ....
For the GID/SID : we can use beforeQuestionRender.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #116955 by SteveCohen
SteveCohen replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.
Ah! Thank you Denis! That was the help I needed.

I've now added the SID code, so survey admins can now enable/disable tracking. I'll commit this to Github in a moment.

I'll look into beforeQuestionRender, too, for other pages and features of the plugin.
The following user(s) said Thank You: DenisChenu

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #116964 by DenisChenu
DenisChenu replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.
Hi,

:)

Added the link at : bugs.limesurvey.org/view.php?id=7565

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #148545 by Mazi
Mazi replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.
Why don't we add this one as a core plugin?


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #148612 by DenisChenu
DenisChenu replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.
I see a good reason currently : this plugin use hack with afterPluginLoad currently. This can be fixed now using beforeControllerAction, but must be done.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
1 year 3 months ago #148617 by Mazi
Mazi replied the topic: A new plugin: Piwik for Limesurvey -- your comments appreciated.

DenisChenu wrote: I see a good reason currently : this plugin use hack with afterPluginLoad currently. This can be fixed now using beforeControllerAction, but must be done.

But that should be doable for the next major release I guess?!


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!