Skip to main content

Questionnaire Integration

RxScale provides embeddable medical questionnaires that collect patient information for doctor consultations. These questionnaires can be created and customized through the RxScale Admin Tool.

Installation

On the questionnaire detail page in the Admin Tool, you’ll find an installation script. Questionnaire releases are versioned, allowing you to test new versions safely. Add the following to your page:
<!-- Placeholder for the questionnaire -->
<div id="rxscale_questionnaire"></div>

<!-- Assign your questionnaire UID -->
<script>
  window.rxscale_questionnaire_uid = "YOUR_QUESTIONNAIRE_UID";
</script>

<!-- Main JS for rendering -->
<script defer src="https://snippets.rxscale.com/v2.7/index.js"></script>

<!-- Default styling -->
<link href="https://snippets.rxscale.com/v2.7/index.css" rel="stylesheet" />

<!-- Optional: Custom styling -->
<link href="https://customizations.rxscale.com/YOUR_QUESTIONNAIRE_UID/css/customization.css" rel="stylesheet" />
Replace YOUR_QUESTIONNAIRE_UID with the UID from your Admin Tool questionnaire detail page.
RxScale automatically renders the questionnaire and responds to its configured type:
  • Product Recommender — Displays a recommendation flow based on patient answers
  • Direct To Cart — Redirects users to the cart after completion (unless otherwise configured)

Event Hooks

RxScale supports optional JavaScript hooks that trigger on specific events. These hooks are independent and modular.

Window Event Handler

After a successful questionnaire submission, RxScale invokes a callback named rxscaleQuestionnaireCompleted:
window.rxscaleQuestionnaireCompleted = ({ submissionId }) => {
  // Custom logic, e.g., redirect or analytics
};

DataLayer (Google Tag Manager)

RxScale pushes structured events into the dataLayer object for Google Tag Manager integration. Events are triggered on page transitions and upon questionnaire completion. Available variables:
  • nextStep — Next step identifier
  • previousStep — Previous step identifier
  • stepName — Current step name
  • questionnaireVersion — Questionnaire version
  • questionnaireName — Questionnaire name
  • questionnaireId — Questionnaire UID

Klaviyo Integration

The Klaviyo snippet must be installed on your webpage for this integration to function.
When a user answers a questionnaire, their response data can identify a Klaviyo profile or trigger an event via the existing Klaviyo SDK on your site.

Helium Integration

The Helium snippet must be installed on your webpage for this integration to function.
User responses can identify or create a Helium account, enabling features like pre-filling login fields based on previously submitted answers.

Attaching Submissions to Orders

To associate a questionnaire submission with a Shopify order, include identifying metadata in the order. The required information can be stored at the order level or within each order item.

Required Properties

PropertyRequired ForDescription
_anamnesis_uidRxScale questionnairesLinks the submission to the order
_external_submission_identifierExternal providersYour external submission ID
_external_provider_uidExternal providersYour external provider UID
If both order-level and item-level properties are present, the item-level property takes precedence.

Example: RxScale Questionnaire

fetch('/cart/update.js', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    attributes: {
      _anamnesis_uid: "SUBMISSION_UID"
    }
  })
});

Example: External Questionnaire Provider

fetch('/cart/update.js', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    attributes: {
      _external_submission_identifier: "YOUR_EXTERNAL_ID",
      _external_provider_uid: "YOUR_PROVIDER_UID"
    }
  })
});
Storing _anamnesis_uid at the order level allows Shopify to duplicate orders if needed (e.g., via reorder functionality).

Pharmacy Selection

To associate a selected pharmacy with a submission, send the pharmacy information to the RxScale API:
fetch(`https://api.rxscale.com/api/v3-1/anamnesis/${anamnesis_uid}/attributes/pharmacy`, {
  method: 'PUT',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    key: "pharmacy_email",
    value: pharmacyEmail,    // empty string if pharmacy uses API integration
    pharmacy_uid: pharmacyUid
  })
});
If the selected pharmacy receives data through an API integration (no email), pass an empty string for the value field.

Patient Status Check

After Shopify login, check when a patient last signed an anamnesis using their customer ID:
const response = await fetch(
  "https://api.rxscale.com/api/v0/patient/intent" +
  "?shop_customer_id=CUSTOMER_ID" +
  "&shop_identifier=YOUR_SHOP" +
  "&intent=INTENT_NAME"
);
const data = await response.json();
console.log(data.return_code);
The questionnaire must be tagged with the intent in the Admin Tool for this to work.

Return Codes

CodeMeaning
100No previous submission, or last signed submission older than 24 months
200Last signed submission between 12 and 24 months ago
300Last signed submission within the last 12 months
Example response:
{
  "return_code": 300
}