API service for a “click counter”, e.g. for creating simple one-click email surveys.
Made by the team at Weld (www.weld.io), the code-free app and web creation tool:
-
Create a new survey (see “Create new survey” under API below).
-
Send an email to a group of users with multi-choice questions:
“What flavour is your favourite?
- Chocolate (link to
http://localhost:3004/flavour_survey/chocolate?user=[USER_ID]
)- Strawberry (link to
http://localhost:3004/flavour_survey/strawberry?user=[USER_ID]
)- Vanilla (link to
http://localhost:3004/flavour_survey/vanilla?user=[USER_ID]
)”
or:
“How likely is it you would recommend our product (1-3, where 3 is best)?
- (link to
http://localhost:3004/recommend_survey/1?user=[USER_ID]
)- (link to
http://localhost:3004/recommend_survey/2?user=[USER_ID]
)- (link to
http://localhost:3004/recommend_survey/3?user=[USER_ID]
)”
[USER_ID] can be any unique identifier for the user (email, internal user ID), and verifies that each user is only counted once, and that each user only gets one vote.
- See a report on what the users clicked the most:
http://localhost:3004/surveys?password=MYPASSWORD
flavour_survey
- chocolate: 42
- strawberry: 25
- vanilla: 7
Just start with:
# Set password used in API requests
export ONECLICKSURVEY_PASSWORD=MYPASSWORD
grunt
Server will default to http://localhost:3004
name
: your own unique name/reference to this survey.option
: the choice that was clicked.redirectUrl
: where to forward the user after clicking.
List surveys
curl http://localhost:3004/api/surveys?password=MYPASSWORD
Create new survey:
curl -X POST -H "Content-Type: application/json" -d '{ "name": "my_survey", "redirectUrl": "http://www.google.com" }' http://localhost:3004/api/surveys?password=MYPASSWORD
Update survey:
curl -X PUT -H "Content-Type: application/json" -d '{ "name": "my_new_survey", "redirectUrl": "https://duckduckgo.com" }' http://localhost:3004/api/surveys/548cbb2b1ad50708212193d8?password=MYPASSWORD
Delete survey:
curl -X DELETE http://localhost:3004/api/surveys/5477a6f88906b9fc766c843e?password=MYPASSWORD
Delete all surveys:
curl -X DELETE http://localhost:3004/api/surveys/ALL?password=MYPASSWORD
Based on the Yeoman Express generator with the "MVC" option. Built on Node.js, Express (with EJS) and MongoDB.
# Set up and configure app
heroku create MYAPPNAME
heroku addons:add mongolab
heroku config:set NODE_ENV=production
# Set password used in API requests
heroku config:set ONECLICKSURVEY_PASSWORD=MYPASSWORD
- Send
user
andoption
on to final destination in a customizable format, to support e.g. Google Forms. - Customizable
redirectUrl
for each option (e.g. as click URL parameter). - Use pure 302 redirect instead of HTML page.
- Suggestion: Use
name
instead ofid
in all routes.