Survey results - using API to get count
What is the best way -- or at least what are the options for showing the number of people who have taken a survey?
So far the best to me looks like having the survey add people to a group, then using the API to get the group members, and getting the totals from the header or that.
What I was hoping though was that I could get a number by src code or the like. Any way to do this?
Also (as an alternate) -- is there any way to use a convio thermometer with Surveys? (I think the answer is no, but I want to confirm)
Thanks,
Adrian
Comments
-
having just tested getGroupMembers -- the downside to this is that it has to be server side (or a logged in admin).
With advocacy where I can get a number with the client. any options for surveys? Without having some server side code elsewhere?
thanks,
Adrian
0 -
Adrian Cotter:
having just tested getGroupMembers -- the downside to this is that it has to be server side (or a logged in admin).
With advocacy where I can get a number with the client. any options for surveys? Without having some server side code elsewhere?
thanks,
Adrian
I think you could use ajax to get the number out of the "number taken" column for the appropriate row here: https://secure.sierraclub.org/site/SSurvey
0 -
Chris Backus:
I think you could use ajax to get the number out of the "number taken" column for the appropriate row here: https://secure.sierraclub.org/site/SSurvey
Though there's nothing in the Survey API that allows you to get back the number of responses for a Survey, there is an S-Tag that can do this (S28), so this is a good example of something where you can "roll your own" API.
Create a PageBuilder page called getSurveyResults and throw this in its contents:
[[U8:text/javascript]][[?xx::x[[S334:callback]]x::::[[S334:callback]](]]{"results": "[[T6:[[E28:REPORTING:[[S334:survey_id]]:[[S334:question_id]]:0:0:0]]]]"}[[?xx::x[[S334:callback]]x:::]]Then call this page like so:
http://action.sierraclub.org/site/PageServer?pagename=getSurveyResults&pgwrap=n&survey_id=1234&question_id=5678&callback=?
You'll of course need to change the survey_id and question_id. The S28 tag reports on the number of people who have answered a particular question, so you need to provide some required question's ID, like, say, the Constituent Registration Information question.
This little "API" will return JSONP. The result object will be a table, and I'm assuming you only want the actual number. Here's som jQuery that should take care of that:
$.ajax({
dataType: 'jsonp',
success: function(data) {
var numResponses = $(data.results).find('p:eq(1)').html();
console.log(numResponses);
},
url: 'http://action.sierraclub.org/site/PageServer?pagename=getSurveyResults&pgwrap=n&survey_id=1234&question_id=5678&callback=?'
});0 -
Noah Cooper:
Though there's nothing in the Survey API that allows you to get back the number of responses for a Survey, there is an S-Tag that can do this (S28), so this is a good example of something where you can "roll your own" API.
Create a PageBuilder page called getSurveyResults and throw this in its contents:
[[U8:text/javascript]][[?xx::x[[S334:callback]]x::::[[S334:callback]](]]{"results": "[[T6:[[E28:REPORTING:[[S334:survey_id]]:[[S334:question_id]]:0:0:0]]]]"}[[?xx::x[[S334:callback]]x:::]]Then call this page like so:
http://action.sierraclub.org/site/PageServer?pagename=getSurveyResults&pgwrap=n&survey_id=1234&question_id=5678&callback=?
You'll of course need to change the survey_id and question_id. The S28 tag reports on the number of people who have answered a particular question, so you need to provide some required question's ID, like, say, the Constituent Registration Information question.
This little "API" will return JSONP. The result object will be a table, and I'm assuming you only want the actual number. Here's som jQuery that should take care of that:
$.ajax({
dataType: 'jsonp',
success: function(data) {
var numResponses = $(data.results).find('p:eq(1)').html();
console.log(numResponses);
},
url: 'http://action.sierraclub.org/site/PageServer?pagename=getSurveyResults&pgwrap=n&survey_id=1234&question_id=5678&callback=?'
});Thanks very much Noah. Works well.
So if I wanted to find the source of a pledge (and so I can then compare their numbers). I could either
> have separate surveys.
> have one survey with questions for each possible source (that are hidden from the user on a custom form where I can change the answers depending on some querystring parameter).
The idea is we want to set up a competition to see what chapter can drive the most survey submissions (which is an RSVP more or less). So they'll all have a link they use.
0 -
Adrian Cotter:
Thanks very much Noah. Works well.
So if I wanted to find the source of a pledge (and so I can then compare their numbers). I could either
> have separate surveys.
> have one survey with questions for each possible source (that are hidden from the user on a custom form where I can change the answers depending on some querystring parameter).
The idea is we want to set up a competition to see what chapter can drive the most survey submissions (which is an RSVP more or less). So they'll all have a link they use.
A seperate questions. Is there a way to get a count of donations?
0 -
Noah Cooper:
Though there's nothing in the Survey API that allows you to get back the number of responses for a Survey, there is an S-Tag that can do this (S28), so this is a good example of something where you can "roll your own" API.
Create a PageBuilder page called getSurveyResults and throw this in its contents:
[[U8:text/javascript]][[?xx::x[[S334:callback]]x::::[[S334:callback]](]]{"results": "[[T6:[[E28:REPORTING:[[S334:survey_id]]:[[S334:question_id]]:0:0:0]]]]"}[[?xx::x[[S334:callback]]x:::]]Then call this page like so:
http://action.sierraclub.org/site/PageServer?pagename=getSurveyResults&pgwrap=n&survey_id=1234&question_id=5678&callback=?
You'll of course need to change the survey_id and question_id. The S28 tag reports on the number of people who have answered a particular question, so you need to provide some required question's ID, like, say, the Constituent Registration Information question.
This little "API" will return JSONP. The result object will be a table, and I'm assuming you only want the actual number. Here's som jQuery that should take care of that:
$.ajax({
dataType: 'jsonp',
success: function(data) {
var numResponses = $(data.results).find('p:eq(1)').html();
console.log(numResponses);
},
url: 'http://action.sierraclub.org/site/PageServer?pagename=getSurveyResults&pgwrap=n&survey_id=1234&question_id=5678&callback=?'
});Thanks, Noah!
I'm new to S-tags, but would love to use this feature. Should "E28:REPORTING" be "S28:REPORTING"?
I tried both, and with the E28 version I get nothing, and the S28 version I see all zeros, even though the survey has responses:
Any help you could give would be much appreciated!
thanks,
Danielle
0 -
Danielle Cranmer:
Thanks, Noah!
I'm new to S-tags, but would love to use this feature. Should "E28:REPORTING" be "S28:REPORTING"?
I tried both, and with the E28 version I get nothing, and the S28 version I see all zeros, even though the survey has responses:
Any help you could give would be much appreciated!
thanks,
Danielle
Hey Danielle!
It should be E28 not S28. E-Tags are the same as S-Tags, except they have parameters that are themselves S-Tags, as seen in the code I provided here. The "E" stands for "evaluated" -- the tags are rendered from the inside out, allowing for the parameters to be evaluated before the outer tag itself.
I took a look at the source of your page and the problem is that you've substituted "survey_id" and "question_id" with actual values for your Survey:
[[U8:text/javascript]][[?xx::x[[S334:callback]]x::::[[S334:callback]](]]{"results": "[[T6:[[S28:REPORTING:[[S334:1381]]:[[S334:1424]]:0:0:0]]]]"}[[?xx::x[[S334:callback]]x:::]]You should be able to copy and paste the code exactly as it is without substituting any values:
[[U8:text/javascript]][[?xx::x[[S334:callback]]x::::[[S334:callback]](]]{"results": "[[T6:[[E28:REPORTING:[[S334:survey_id]]:[[S334:question_id]]:0:0:0]]]]"}[[?xx::x[[S334:callback]]x:::]]This code is written to dynamically retrieve the survey_id and question_id from the URL when the page is loaded. This is what the S334 tag does -- it returns the value of a named GET query parameter.
0 -
Noah Cooper:
Hey Danielle!
It should be E28 not S28. E-Tags are the same as S-Tags, except they have parameters that are themselves S-Tags, as seen in the code I provided here. The "E" stands for "evaluated" -- the tags are rendered from the inside out, allowing for the parameters to be evaluated before the outer tag itself.
I took a look at the source of your page and the problem is that you've substituted "survey_id" and "question_id" with actual values for your Survey:
[[U8:text/javascript]][[?xx::x[[S334:callback]]x::::[[S334:callback]](]]{"results": "[[T6:[[S28:REPORTING:[[S334:1381]]:[[S334:1424]]:0:0:0]]]]"}[[?xx::x[[S334:callback]]x:::]]You should be able to copy and paste the code exactly as it is without substituting any values:
[[U8:text/javascript]][[?xx::x[[S334:callback]]x::::[[S334:callback]](]]{"results": "[[T6:[[E28:REPORTING:[[S334:survey_id]]:[[S334:question_id]]:0:0:0]]]]"}[[?xx::x[[S334:callback]]x:::]]This code is written to dynamically retrieve the survey_id and question_id from the URL when the page is loaded. This is what the S334 tag does -- it returns the value of a named GET query parameter.
Thank you, Noah! I was able to get the table containing the count:
However, when I tried the jquery in a page, I'm getting nothing:
http://my.rainforest-alliance.org/site/PageNavigator/test.html
any advice?
thank you!
Danielle
0 -
Danielle Cranmer:
Thank you, Noah! I was able to get the table containing the count:
However, when I tried the jquery in a page, I'm getting nothing:
http://my.rainforest-alliance.org/site/PageNavigator/test.html
any advice?
thank you!
Danielle
Danielle,
It's working! Right now the code simply logs the count to the console -- if you open a console you should see the count there. If you want to do something more with it, like display the value somewhere on a page, you'd need to update the JavaScript.0 -
Noah Cooper:
Danielle,
It's working! Right now the code simply logs the count to the console -- if you open a console you should see the count there. If you want to do something more with it, like display the value somewhere on a page, you'd need to update the JavaScript.Got it!
Noah, you are a genious. Thank you so much!
Danielle
0 -
Noah Cooper:
Danielle,
It's working! Right now the code simply logs the count to the console -- if you open a console you should see the count there. If you want to do something more with it, like display the value somewhere on a page, you'd need to update the JavaScript.Hey Noah, as usual this is an awesome tip. One problem I'm having though is that I want to load this on a secure page. So I switched the component to an secure component but it is not working now. Any thoughts?
0 -
Josh Weinstein:
Hey Noah, as usual this is an awesome tip. One problem I'm having though is that I want to load this on a secure page. So I switched the component to an secure component but it is not working now. Any thoughts?
Josh,
Can you share a link to the page you're having problems on?
0 -
Noah Cooper:
Danielle,
It's working! Right now the code simply logs the count to the console -- if you open a console you should see the count there. If you want to do something more with it, like display the value somewhere on a page, you'd need to update the JavaScript.Hi Noah,
I have one more question for you. How can I capture the responses for two or THREE surveys in this code and have the numResponses be the combined number?
Thanks!
0 -
Old thread but still good for the rest of us using Survey.
I've followed the instructions above, getting the GET response but when trying to render it on a page, I can't seem to be getting anything back.
Tried a few arrangements like swapping out version of Jquery, calling the function in a few ways, noConflict, etc. but seem to not get any returned values. All pages are set to reusable and Secure https (and i'm calling the secure URL, which rendered correct for Raw Data) What do you think may be missing??
Raw Data:
https://secure.americares.org/site/SPageServer/?question_id=4804&survey_id=3201&pagename=zTestRenderingSTag_getSurveyResults&pgwrap=n&callback=?
Rendered Results on a Page:
https://secure.americares.org/site/SPageNavigator/zTestRenderingSTag_RenderedResults.html
Appreciate any help anyone may have
0 -
M OConnell:
Old thread but still good for the rest of us using Survey.
I've followed the instructions above, getting the GET response but when trying to render it on a page, I can't seem to be getting anything back.
Tried a few arrangements like swapping out version of Jquery, calling the function in a few ways, noConflict, etc. but seem to not get any returned values. All pages are set to reusable and Secure https (and i'm calling the secure URL, which rendered correct for Raw Data) What do you think may be missing??
Raw Data:
https://secure.americares.org/site/SPageServer/?question_id=4804&survey_id=3201&pagename=zTestRenderingSTag_getSurveyResults&pgwrap=n&callback=?
Rendered Results on a Page:
https://secure.americares.org/site/SPageNavigator/zTestRenderingSTag_RenderedResults.html
Appreciate any help anyone may haveIt looks like when content was migrated to the new Community a while back, some of the code above got changed to emojis! Change:
[[?xx::x[[S334:callback]]x::::smileyhappy:]]
... to:
[[?xx::x[[S334:callback]]x::::)]]0 -
Ha! I had assumed it was a symbolic "it works!" that was added in the code. Appreciate your answering such an old thread, Noah!0
Categories
- All Categories
- Shannon parent
- shannon 2
- shannon 1
- 21 Advocacy DC Users Group
- 14 BBCRM PAG Discussions
- 89 High Education Program Advisory Group (HE PAG)
- 28 Luminate CRM DC Users Group
- 8 DC Luminate CRM Users Group
- Luminate PAG
- 5.9K Blackbaud Altru®
- 58 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 409 bbcon®
- 2.1K Blackbaud CRM™ and Blackbaud Internet Solutions™
- donorCentrics®
- 1.1K Blackbaud eTapestry®
- 2.8K Blackbaud Financial Edge NXT®
- 1.1K Blackbaud Grantmaking™
- 527 Education Management Solutions for Higher Education
- 1 JustGiving® from Blackbaud®
- 4.6K Education Management Solutions for K-12 Schools
- Blackbaud Luminate Online & Blackbaud TeamRaiser
- 16.4K Blackbaud Raiser's Edge NXT®
- 4.1K SKY Developer
- 547 ResearchPoint™
- 151 Blackbaud Tuition Management™
- 1 YourCause® from Blackbaud®
- 61 everydayhero
- 3 Campaign Ideas
- 58 General Discussion
- 115 Blackbaud ID
- 87 K-12 Blackbaud ID
- 6 Admin Console
- 949 Organizational Best Practices
- 353 The Tap (Just for Fun)
- 235 Blackbaud Community Feedback Forum
- 55 Admissions Event Management EAP
- 18 MobilePay Terminal + BBID Canada EAP
- 36 EAP for New Email Campaigns Experience in Blackbaud Luminate Online®
- 109 EAP for 360 Student Profile in Blackbaud Student Information System
- 41 EAP for Assessment Builder in Blackbaud Learning Management System™
- 9 Technical Preview for SKY API for Blackbaud CRM™ and Blackbaud Altru®
- 55 Community Advisory Group
- 46 Blackbaud Community Ideas
- 26 Blackbaud Community Challenges
- 7 Security Testing Forum
- 1.1K ARCHIVED FORUMS | Inactive and/or Completed EAPs
- 3 Blackbaud Staff Discussions
- 7.7K ARCHIVED FORUM CATEGORY [ID 304]
- 1 Blackbaud Partners Discussions
- 1 Blackbaud Giving Search™
- 35 EAP Student Assignment Details and Assignment Center
- 39 EAP Core - Roles and Tasks
- 59 Blackbaud Community All-Stars Discussions
- 20 Blackbaud Raiser's Edge NXT® Online Giving EAP
- Diocesan Blackbaud Raiser’s Edge NXT® User’s Group
- 2 Blackbaud Consultant’s Community
- 43 End of Term Grade Entry EAP
- 92 EAP for Query in Blackbaud Raiser's Edge NXT®
- 38 Standard Reports for Blackbaud Raiser's Edge NXT® EAP
- 12 Payments Assistant for Blackbaud Financial Edge NXT® EAP
- 6 Ask an All Star (Austen Brown)
- 8 Ask an All-Star Alex Wong (Blackbaud Raiser's Edge NXT®)
- 1 Ask an All-Star Alex Wong (Blackbaud Financial Edge NXT®)
- 6 Ask an All-Star (Christine Robertson)
- 21 Ask an Expert (Anthony Gallo)
- Blackbaud Francophone Group
- 22 Ask an Expert (David Springer)
- 4 Raiser's Edge NXT PowerUp Challenge #1 (Query)
- 6 Ask an All-Star Sunshine Reinken Watson and Carlene Johnson
- 4 Raiser's Edge NXT PowerUp Challenge: Events
- 14 Ask an All-Star (Elizabeth Johnson)
- 7 Ask an Expert (Stephen Churchill)
- 2025 ARCHIVED FORUM POSTS
- 322 ARCHIVED | Financial Edge® Tips and Tricks
- 164 ARCHIVED | Raiser's Edge® Blog
- 300 ARCHIVED | Raiser's Edge® Blog
- 441 ARCHIVED | Blackbaud Altru® Tips and Tricks
- 66 ARCHIVED | Blackbaud NetCommunity™ Blog
- 211 ARCHIVED | Blackbaud Target Analytics® Tips and Tricks
- 47 Blackbaud CRM Higher Ed Product Advisory Group (HE PAG)
- Luminate CRM DC Users Group
- 225 ARCHIVED | Blackbaud eTapestry® Tips and Tricks
- 1 Blackbaud eTapestry® Know How Blog
- 19 Blackbaud CRM Product Advisory Group (BBCRM PAG)
- 1 Blackbaud K-12 Education Solutions™ Blog
- 280 ARCHIVED | Mixed Community Announcements
- 3 ARCHIVED | Blackbaud Corporations™ & Blackbaud Foundations™ Hosting Status
- 1 npEngage
- 24 ARCHIVED | K-12 Announcements
- 15 ARCHIVED | FIMS Host*Net Hosting Status
- 23 ARCHIVED | Blackbaud Outcomes & Online Applications (IGAM) Hosting Status
- 22 ARCHIVED | Blackbaud DonorCentral Hosting Status
- 14 ARCHIVED | Blackbaud Grantmaking™ UK Hosting Status
- 117 ARCHIVED | Blackbaud CRM™ and Blackbaud Internet Solutions™ Announcements
- 50 Blackbaud NetCommunity™ Blog
- 169 ARCHIVED | Blackbaud Grantmaking™ Tips and Tricks
- Advocacy DC Users Group
- 718 Community News
- Blackbaud Altru® Hosting Status
- 104 ARCHIVED | Member Spotlight
- 145 ARCHIVED | Hosting Blog
- 149 JustGiving® from Blackbaud® Blog
- 97 ARCHIVED | bbcon® Blogs
- 19 ARCHIVED | Blackbaud Luminate CRM™ Announcements
- 161 Luminate Advocacy News
- 187 Organizational Best Practices Blog
- 67 everydayhero Blog
- 52 Blackbaud SKY® Reporting Announcements
- 17 ARCHIVED | Blackbaud SKY® Reporting for K-12 Announcements
- 3 Luminate Online Product Advisory Group (LO PAG)
- 81 ARCHIVED | JustGiving® from Blackbaud® Tips and Tricks
- 1 ARCHIVED | K-12 Conference Blog
- Blackbaud Church Management™ Announcements
- ARCHIVED | Blackbaud Award Management™ and Blackbaud Stewardship Management™ Announcements
- 1 Blackbaud Peer-to-Peer Fundraising™, Powered by JustGiving® Blogs
- 39 Tips, Tricks, and Timesavers!
- 56 Blackbaud Church Management™ Resources
- 154 Blackbaud Church Management™ Announcements
- 1 ARCHIVED | Blackbaud Church Management™ Tips and Tricks
- 11 ARCHIVED | Blackbaud Higher Education Solutions™ Announcements
- 7 ARCHIVED | Blackbaud Guided Fundraising™ Blog
- 2 Blackbaud Fundraiser Performance Management™ Blog
- 9 Foundations Events and Content
- 14 ARCHIVED | Blog Posts
- 2 ARCHIVED | Blackbaud FIMS™ Announcement and Tips
- 59 Blackbaud Partner Announcements
- 10 ARCHIVED | Blackbaud Impact Edge™ EAP Blogs
- 1 Community Help Blogs
- Diocesan Blackbaud Raiser’s Edge NXT® Users' Group
- Blackbaud Consultant’s Community
- Blackbaud Francophone Group
- 1 BLOG ARCHIVE CATEGORY
- Blackbaud Community™ Discussions
- 8.3K Blackbaud Luminate Online® & Blackbaud TeamRaiser® Discussions
- 5.7K Jobs Board