- Posts: 7
- Thank you received: 3
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
A new plugin: Piwik for Limesurvey -- your comments appreciated.
- SteveCohen
- Topic Author
- Offline
- New Member
Less
More
9 years 1 month ago #116615
by SteveCohen
A new plugin: Piwik for Limesurvey -- your comments appreciated. was created by SteveCohen
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 [url] github.com/SteveCohen/Piwik-for-Limesurvey [/url].
Comments very welcome --desired, actually, becuase I've mostly hacked this together using other plugins as examples...
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.
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 [url] github.com/SteveCohen/Piwik-for-Limesurvey [/url].
Comments very welcome --desired, actually, becuase I've mostly hacked this together using other plugins as examples...
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
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
9 years 1 month ago #116629
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on 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
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
- SteveCohen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 3
9 years 1 month ago #116646
by SteveCohen
Replied by SteveCohen on 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:
The topic has been locked.
- SteveCohen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 3
9 years 1 month ago #116648
by SteveCohen
Replied by SteveCohen on 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.
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
9 years 1 month ago #116649
by Mazi
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
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic A new plugin: Piwik for Limesurvey -- your comments appreciated.
Topic moved.SteveCohen wrote: Mods, would you move this to the 'plugins' forum? My apologies for posting in the wrong place.
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
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
- SteveCohen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 3
9 years 1 month ago #116691
by SteveCohen
Replied by SteveCohen on topic A new plugin: Piwik for Limesurvey -- your comments appreciated.
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.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?
The topic has been locked.
- SteveCohen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 3
9 years 1 month ago - 9 years 1 month ago #116854
by SteveCohen
Replied by SteveCohen on 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:
...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?
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:
Code:
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: 9 years 1 month ago by SteveCohen.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
9 years 1 month ago #116861
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on 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
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 , plugin development .
I don't answer to private message.
The topic has been locked.
- SteveCohen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 3
9 years 1 month ago - 9 years 1 month ago #116894
by SteveCohen
Replied by SteveCohen on 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:
In the meantime, I've put my current code up ([URL] github.com/SteveCohen/Piwik-for-Limesurvey [/URL]). This has placeholder code for the disable-per-survey feature.
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:
- beforeSurveyPage adds adds JS script to make an AJAX request to a php script. This request includes the surveyID.
- 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??)
- Once AJAX is done, if the result was true, add the tracking code. .
In the meantime, I've put my current code up ([URL] github.com/SteveCohen/Piwik-for-Limesurvey [/URL]). This has placeholder code for the disable-per-survey feature.
Last edit: 9 years 1 month ago by SteveCohen. Reason: Didn't need to include Denis' entire message in quote :)
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
9 years 1 month ago #116903
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on 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
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 , plugin development .
I don't answer to private message.
The topic has been locked.
- SteveCohen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 3
9 years 1 month ago #116955
by SteveCohen
Replied by SteveCohen on 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.
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
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
9 years 1 month ago #116964
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic A new plugin: Piwik for Limesurvey -- your comments appreciated.
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.