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
  • SteveCohen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 10 months ago #116615 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... :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
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 10 months ago #116629 by Mazi
Thanks for sharing your solution. Can you share a screenshot of the plugin settings?

Best regards/Beste Grüße,
Dr. Marcel Minke
The topic has been locked.
  • SteveCohen
  • SteveCohen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 10 months ago #116646 by SteveCohen
Sure; see attached. Pretty simple for the moment. "What should i put here?" is a link to the Piwik docs.
The topic has been locked.
  • SteveCohen
  • SteveCohen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 10 months ago #116648 by SteveCohen
Mods, would you move this to the 'plugins' forum? My apologies for posting in the wrong place.
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 10 months ago #116649 by Mazi

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
The topic has been locked.
  • SteveCohen
  • SteveCohen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 10 months ago #116691 by SteveCohen

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.
The topic has been locked.
  • SteveCohen
  • SteveCohen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 10 months ago - 9 years 10 months ago #116854 by SteveCohen
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:
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 10 months ago by SteveCohen.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
9 years 10 months ago #116861 by DenisChenu
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 support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
  • SteveCohen
  • SteveCohen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 10 months ago - 9 years 10 months ago #116894 by SteveCohen
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 ([URL] github.com/SteveCohen/Piwik-for-Limesurvey [/URL]). This has placeholder code for the disable-per-survey feature.
Last edit: 9 years 10 months ago by SteveCohen. Reason: Didn't need to include Denis' entire message in quote :)
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
9 years 10 months ago #116903 by DenisChenu
No,

surveyid are in the input : www.limesurvey.org/manual/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 support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
  • SteveCohen
  • SteveCohen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 10 months ago #116955 by SteveCohen
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
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
9 years 10 months ago #116964 by DenisChenu
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 support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
Moderators: holchtpartner

Lime-years ahead

Online-surveys for every purse and purpose