trigger the url without visiting it

More
4 years 2 months ago #93568 by agabriel
agabriel created the topic: trigger the url without visiting it
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:
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");
}
});
 
}

Please Log in to join the conversation.

More
4 years 2 months ago #93582 by DenisChenu
DenisChenu replied the 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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
4 years 2 months ago #93587 by Ben_V
Ben_V replied the 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)

Please Log in to join the conversation.

More
4 years 2 months ago #93650 by agabriel
agabriel replied the 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

Please Log in to join the conversation.

More
4 years 2 months ago #93651 by agabriel
agabriel replied the 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

Please Log in to join the conversation.

More
4 years 2 months ago #93667 by DenisChenu
DenisChenu replied the 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.
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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
4 years 2 months ago #94070 by agabriel
agabriel replied the 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?

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now