Welcome, Guest
Username: Password: Remember me

TOPIC: trigger the url without visiting it

trigger the url without visiting it 1 year 1 month ago #93568

  • agabriel
  • agabriel's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 9
  • Karma: 0
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");
}
});
 
}
The administrator has disabled public write access.

trigger the url without visiting it 1 year 1 month ago #93582

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 5854
  • Thank you received: 716
  • Karma: 222
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
The administrator has disabled public write access.

trigger the url without visiting it 1 year 1 month ago #93587

  • Ben_V
  • Ben_V's Avatar
  • OFFLINE
  • Platinum Lime
  • Posts: 933
  • Thank you received: 193
  • Karma: 62
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

goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche)
goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar)
goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de...
The administrator has disabled public write access.

trigger the url without visiting it 1 year 1 month ago #93650

  • agabriel
  • agabriel's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 9
  • Karma: 0
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 administrator has disabled public write access.

trigger the url without visiting it 1 year 1 month ago #93651

  • agabriel
  • agabriel's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 9
  • Karma: 0
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 administrator has disabled public write access.

trigger the url without visiting it 1 year 1 month ago #93667

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 5854
  • Thank you received: 716
  • Karma: 222
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
The administrator has disabled public write access.

trigger the url without visiting it 1 year 1 month ago #94070

  • agabriel
  • agabriel's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 9
  • Karma: 0
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 administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.130 seconds
Donation Image