I need to send a simple (one-off) survey to users and capture their answer in the most unobstructive way. It's one question with a yes/no answer.
Setting up mailchimp(or other service) seems overkill, so I figured I can just use craft.
Would there be any downsides/potential problems doing it this way.
I create a new section and import (with feedme) each email as an entry, I also assign a unique id to each email.
Then, I would send an email with yes / no buttons that have a link with the answer as a query string, like this
https://www.domain.com/survey?userid=456&answer=no
orhttps://www.domain.com/survey?userid=456&answer=yes
The entry template has this code that updates the answer field upon visiting the page using the configure function.
{# set the custom user id from the querystring #}
{% set userId = craft.app.request.getParam('userid') %}
{# set the answer from the querystring #}
{% set answer = craft.app.request.getParam('answer') %}
{% if userId is not null %}
{% set entry = craft.entries
.section('survey')
.surveyUserId(userId)
.one() %}
{# Check if the answer field is empty #}
{% if entry.surveyAnswer is empty %}
{% if answer == 'yes' %}
{% do configure(entry, { surveyAnswer: 'Yes' }) %}
{% do craft.app.elements.saveElement(entry) %}
{% endif %}
{% if answer == 'no' %}
{% do configure(entry, { surveyAnswer: 'No' }) %}
{% do craft.app.elements.saveElement(entry) %}
{% endif %}
{% else %}
It seems you've already submitted your answer.
{% endif %}
{% else %}
No user id defined
{% endif %}