Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

trigger the url without visiting it

  • agabriel
  • agabriel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 2 weeks ago #93568 by agabriel
trigger the url without visiting it was created by agabriel
Hi,

I have a survey that need to tract if they click the Facebook share button in the completed page.
- I used a url to solve this. But the problem is the user is navigating away from the completed page when they click the share button.

How can i trigger the url without visiting it?

I tried with ajax but its not working

Here's my example code:
Code:
function shared(){
//NOT WORKING
$.ajax({
type: "POST",
url: "http://domainname/surveys/index.php?sid=XXXXXXlang=en&000000X0000X0000=yes", //used to record that they clicked the share button
success: function(data){
alert("thank you for sharing");
}
});
 
}
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 years 2 weeks ago #93582 by DenisChenu
Replied by DenisChenu on topic trigger the url without visiting it
Hello,

There are 2 solution:
- Use your own script in completed page with something like;
example.org/thanks.php?srid={SAVEDID }
This script update the lime_survey_XXXX datatable, line srid.
- Do this before completed, at the last page: clicking shared check "Yes" to a yes/no question

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.
More
11 years 2 weeks ago #93587 by Ben_V
Replied by Ben_V on topic trigger the url without visiting it
Hi,

If you want to store if a respondant was sharing or not, Denis's solution looks good.

If you also want to simply track how many times respondants were clicking on your share button and retrieve the survey ID (and maybe more infos) you should have a look here

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
  • agabriel
  • agabriel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 2 weeks ago #93650 by agabriel
Replied by agabriel on topic trigger the url without visiting it
Hi Denis,

Sorry but i cant do that, the script must run and update the datatable if they click the FB share button in the completed page without navigating away in that same page.

To be exact i place the code in 'assessment.pstpl' because i wanted to share their assessment score in facebook and tracking the click in that button.

Cheers
Ali
The topic has been locked.
  • agabriel
  • agabriel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 2 weeks ago #93651 by agabriel
Replied by agabriel on topic trigger the url without visiting it
Hi Ben,

Thank you for your reply.

But my problem is triggering this link http://domainname/surveys/index.php?sid=XXXXXXlang=en&000000X0000X0000=yes // to update my datatable without navigating away from that page or visiting that link.

Ali
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 years 2 weeks ago #93667 by DenisChenu
Replied by DenisChenu on topic trigger the url without visiting it

agabriel wrote: But my problem is triggering this link http://domainname/surveys/index.php?sid=XXXXXXlang=en&000000X0000X0000=yes // to update my datatable without navigating away from that page or visiting that link.

Then you need to doing it with an ajax call.

Don't use LS to update DB, a clean php file receving {SAVEDID} is better i think.
Code:
jQuery.ajax({
  type: 'GET',
  url: 'http://www.example.com/yourscript.php',
  data: {
    srid: '{SAVEDID}'
  }
});

yourscript just update answers in the survey table of the database srid is the "Textes complets id" of the line.
You can control if $_SESSION is open and is the srid is OK before updating it.

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.
  • agabriel
  • agabriel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 1 week ago #94070 by agabriel
Replied by agabriel on topic trigger the url without visiting it

DenisChenu wrote: yourscript just update answers in the survey table of the database srid is the "Textes complets id" of the line.
You can control if $_SESSION is open and is the srid is OK before updating it.

Denis


Hi Denis,

i dont have any idea what to place yourscript.php to update the srid database

can you please give me a sudo code that i will place in the yourscript.php so it can update the database?
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose