Skip to main content

Decipher Toolbox Integration

This guide will walk you through integrating the DQCToolBox with Decipher Platform Surveys.


📌 Steps to Integrate DQC Toolbox with Decipher​

Step 1: Api Key​

Make sure you have your API_KEY from the DQCO-OP platform. If you don't have one, follow these steps to generate one.

Step 2: Edit the Survey XML​

  1. Navigate to your Decipher Portal:
    👉 Open Decipher Portal
  2. Select your survey.
  3. Go to the navigation bar and click:
    Build → More Tools → Edit XML

Step 2.1: Add Code to execute the Quality Tools on the survey​

Insert the following script after the <survey> tag:

  • Make sure to replace API_KEY with your actual API key.
<style name="global.page.head" wrap="ready"><![CDATA[
(async () => {
try {
const saveDataInForsta = (data) => {
Survey.setPersistent('client_visitor_id', data.participantId);
Survey.setPersistent('client_score', data.deviceScore);
Survey.setPersistent('client_country_code', data.country);
Survey.setPersistent('client_subdivision_name', data.subdivision);
Survey.setPersistent('client_is_duplicate', data.isDuplicate);
Survey.setPersistent('client_survey_id', data.surveyId);
Survey.setPersistent('client_avg_device_score', data.averageDeviceScore);
Survey.setPersistent('client_lowest_device_score', data.lowestDeviceScore);
Survey.setPersistent('client_total_surveys', data.totalSurveys);
const deviceFailures = data.deviceFailures && data.deviceFailures.length ? data.deviceFailures.join(', ') : '';
Survey.setPersistent('client_device_failures', deviceFailures);
Survey.setPersistent('client_completion_rate', data.completionRate);
Survey.setPersistent('client_duplication_rate', data.duplicationRate);
Survey.setPersistent('client_failure_rate', data.failureRate);
Survey.setPersistent('client_qualification_rate', data.qualificationRate);
Survey.setPersistent('client_last_survey_taken', data.lastSurveyTaken);
Survey.setPersistent('client_manual_isq_rate', data.manualISQRate);
Survey.setPersistent('client_automated_isq_rate', data.automatedISQRate);
Survey.setPersistent('client_osq_rate', data.osqRate);
Survey.setPersistent('client_brand_familiarity', data.brandFamiliarity);
Survey.setPersistent('client_open_end', data.openEnd);
Survey.setPersistent('client_speeding', data.speeding);
Survey.setPersistent('client_honey_pot', data.honeyPot);
Survey.setPersistent('client_straightlining', data.straightlining);
Survey.setPersistent('client_distinct_supplier_count', data.distinctSupplierCount);
};

const { DQCToolBox } = await import('https://api.dqco-op.com/tools/toolbox/API_KEY');
const data = await DQCToolBox.getIdentity();
saveDataInForsta(data);
} catch (error) {
console.error('Error in client code:', error);
}
})();
]]></style>
<suspend/>

<exec when="init">
defaultAnswer = 'Submission too quick, data not processed'
defaultSurveyMetricsAnswer = 'No Data'
def save_dqc_data():
defaultDeviceFailuresAnswer = 'None' if getattr(p, 'client_visitor_id', '') else defaultAnswer
dqc_data.d1.val = getattr(p, 'client_visitor_id', '') or defaultAnswer
dqc_data.d2.val = getattr(p, 'client_score', '') or '0'
dqc_data.d3.val = getattr(p, 'client_country_code', '') or defaultAnswer
dqc_data.d4.val = getattr(p, 'client_subdivision_name', '') or defaultAnswer
dqc_data.d5.val = getattr(p, 'client_is_duplicate', True)
dqc_data.d6.val = getattr(p, 'client_survey_id', '') or defaultAnswer
dqc_data.d7.val = getattr(p, 'client_avg_device_score', '') or '0'
dqc_data.d8.val = getattr(p, 'client_lowest_device_score', '') or '0'
dqc_data.d9.val = getattr(p, 'client_total_surveys', '') or '0'
dqc_data.d10.val = getattr(p, 'client_device_failures', '') or defaultDeviceFailuresAnswer
dqc_data.d11.val = getattr(p, 'client_completion_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d12.val = getattr(p, 'client_duplication_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d13.val = getattr(p, 'client_failure_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d14.val = getattr(p, 'client_qualification_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d15.val = getattr(p, 'client_last_survey_taken', '') or defaultSurveyMetricsAnswer
dqc_data.d16.val = getattr(p, 'client_manual_isq_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d17.val = getattr(p, 'client_automated_isq_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d18.val = getattr(p, 'client_osq_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d19.val = getattr(p, 'client_brand_familiarity', '') or '0'
dqc_data.d20.val = getattr(p, 'client_open_end', '') or '0'
dqc_data.d21.val = getattr(p, 'client_speeding', '') or '0'
dqc_data.d22.val = getattr(p, 'client_honey_pot', '') or '0'
dqc_data.d23.val = getattr(p, 'client_straightlining', '') or '0'
dqc_data.d24.val = getattr(p, 'client_distinct_supplier_count', '') or '0'
</exec>

<exec when="submit">
save_dqc_data()
</exec>

Step 2.2.1: Custom surveyId (optional)​

You can add a custom surveyId to the script. This is optional, but it can be useful if you want to track responses from different surveys.

You can leave it empty to use the current URL (hostname+pathname) as the surveyId. This is the default behavior.

const data = await DQCToolBox.getIdentity('Your_Manual_Survey_Id');

Step 2.3: Store All Data at Survey End​

Add the following code at the end of your survey:

<suspend/>

<text
label="dqc_data"
optional="0"
size="25"
translateable="0"
where="execute,survey,report">
<title>DQC Data Holder</title>
<row label="d1">dqc-id</row>
<row label="d2">dqc-device-score</row>
<row label="d3">dqc-country</row>
<row label="d4">dqc-subdivision</row>
<row label="d5">dqc-is-duplicate</row>
<row label="d6">dqc-survey-id</row>
<row label="d7">dqc-average-device-score</row>
<row label="d8">dqc-lowest-device-score</row>
<row label="d9">dqc-total-surveys</row>
<row label="d10">dqc-device-failures</row>
<row label="d11">dqc-completion-rate</row>
<row label="d12">dqc-duplication-rate</row>
<row label="d13">dqc-failure-rate</row>
<row label="d14">dqc-qualification-rate</row>
<row label="d15">dqc-last-survey-taken</row>
<row label="d16">dqc-manual-isq-rate</row>
<row label="d17">dqc-automated-isq-rate</row>
<row label="d18">dqc-osq-rate</row>
<row label="d19">dqc-brand-familiarity</row>
<row label="d20">dqc-open-end</row>
<row label="d21">dqc-speeding</row>
<row label="d22">dqc-honey-pot</row>
<row label="d23">dqc-straightlining</row>
<row label="d24">dqc-distinct-supplier-count</row>
</text>
</survey>

Full XML Survey Example​

Here is a complete example of the final XML, following all the steps above.

Note: the API_KEY shown is not valid—you will need to generate your own.

Full Decipher Accordion XML
<?xml version="1.0" encoding="UTF-8"?>
<survey
alt="Quality Tools Integration - Testing"
autosave="0"
builder:wizardCompleted="1"
builderCompatible="1"
compat="153"
delphi="1"
extraVariables="source,record,decLang,list,userAgent"
fir="on"
html:showNumber="0"
mobile="compat"
mobileDevices="smartphone,tablet,desktop"
name="Survey"
secure="1"
setup="term,decLang,time"
ss:disableBackButton="1"
ss:enableNavigation="1"
ss:hideProgressBar="0"
state="testing">

<style name="global.page.head" wrap="ready"><![CDATA[
(async () => {
try {
const saveDataInForsta = (data) => {
Survey.setPersistent('client_visitor_id', data.participantId);
Survey.setPersistent('client_score', data.deviceScore);
Survey.setPersistent('client_country_code', data.country);
Survey.setPersistent('client_subdivision_name', data.subdivision);
Survey.setPersistent('client_is_duplicate', data.isDuplicate);
Survey.setPersistent('client_survey_id', data.surveyId);
Survey.setPersistent('client_avg_device_score', data.averageDeviceScore);
Survey.setPersistent('client_lowest_device_score', data.lowestDeviceScore);
Survey.setPersistent('client_total_surveys', data.totalSurveys);
const deviceFailures = data.deviceFailures && data.deviceFailures.length ? data.deviceFailures.join(', ') : '';
Survey.setPersistent('client_device_failures', deviceFailures);
Survey.setPersistent('client_completion_rate', data.completionRate);
Survey.setPersistent('client_duplication_rate', data.duplicationRate);
Survey.setPersistent('client_failure_rate', data.failureRate);
Survey.setPersistent('client_qualification_rate', data.qualificationRate);
Survey.setPersistent('client_last_survey_taken', data.lastSurveyTaken);
Survey.setPersistent('client_manual_isq_rate', data.manualISQRate);
Survey.setPersistent('client_automated_isq_rate', data.automatedISQRate);
Survey.setPersistent('client_osq_rate', data.osqRate);
Survey.setPersistent('client_brand_familiarity', data.brandFamiliarity);
Survey.setPersistent('client_open_end', data.openEnd);
Survey.setPersistent('client_speeding', data.speeding);
Survey.setPersistent('client_honey_pot', data.honeyPot);
Survey.setPersistent('client_straightlining', data.straightlining);
Survey.setPersistent('client_distinct_supplier_count', data.distinctSupplierCount);
};

const { DQCToolBox } = await import('https://api.dqco-op.com/tools/toolbox/API_KEY');
const data = await DQCToolBox.getIdentity();
saveDataInForsta(data);
} catch (error) {
console.error('Error in client code:', error);
}
})();
]]></style>
<suspend/>

<exec when="init">
defaultAnswer = 'Submission too quick, data not processed'
defaultSurveyMetricsAnswer = 'No Data'
def save_dqc_data():
defaultDeviceFailuresAnswer = 'None' if getattr(p, 'client_visitor_id', '') else defaultAnswer
dqc_data.d1.val = getattr(p, 'client_visitor_id', '') or defaultAnswer
dqc_data.d2.val = getattr(p, 'client_score', '') or '0'
dqc_data.d3.val = getattr(p, 'client_country_code', '') or defaultAnswer
dqc_data.d4.val = getattr(p, 'client_subdivision_name', '') or defaultAnswer
dqc_data.d5.val = getattr(p, 'client_is_duplicate', True)
dqc_data.d6.val = getattr(p, 'client_survey_id', '') or defaultAnswer
dqc_data.d7.val = getattr(p, 'client_avg_device_score', '') or '0'
dqc_data.d8.val = getattr(p, 'client_lowest_device_score', '') or '0'
dqc_data.d9.val = getattr(p, 'client_total_surveys', '') or '0'
dqc_data.d10.val = getattr(p, 'client_device_failures', '') or defaultDeviceFailuresAnswer
dqc_data.d11.val = getattr(p, 'client_completion_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d12.val = getattr(p, 'client_duplication_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d13.val = getattr(p, 'client_failure_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d14.val = getattr(p, 'client_qualification_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d15.val = getattr(p, 'client_last_survey_taken', '') or defaultSurveyMetricsAnswer
dqc_data.d16.val = getattr(p, 'client_manual_isq_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d17.val = getattr(p, 'client_automated_isq_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d18.val = getattr(p, 'client_osq_rate', '') or defaultSurveyMetricsAnswer
dqc_data.d19.val = getattr(p, 'client_brand_familiarity', '') or '0'
dqc_data.d20.val = getattr(p, 'client_open_end', '') or '0'
dqc_data.d21.val = getattr(p, 'client_speeding', '') or '0'
dqc_data.d22.val = getattr(p, 'client_honey_pot', '') or '0'
dqc_data.d23.val = getattr(p, 'client_straightlining', '') or '0'
dqc_data.d24.val = getattr(p, 'client_distinct_supplier_count', '') or '0'
</exec>

<exec when="submit">
save_dqc_data()
</exec>


<suspend/>

<radio
label="Q1">
<title>Are you human?</title>
<comment>Select one</comment>
<row label="r1">Yes</row>
<row label="r2">No</row>
</radio>

<suspend/>

<radio
label="Q2">
<title>Are you human?</title>
<comment>Select one</comment>
<row label="r1">Yes</row>
<row label="r2">No</row>
</radio>

<suspend/>

<radio
label="Q3">
<title>Are you human?</title>
<comment>Select one</comment>
<row label="r1">Yes</row>
<row label="r2">No</row>
</radio>


<suspend/>

<radio
label="Q4">
<title>Are you human?</title>
<comment>Select one</comment>
<row label="r1">Yes</row>
<row label="r2">No</row>
</radio>

<suspend/>

<text
label="dqc_data"
optional="0"
size="25"
translateable="0"
where="execute,survey,report">
<title>DQC Data Holder</title>
<row label="d1">dqc-id</row>
<row label="d2">dqc-device-score</row>
<row label="d3">dqc-country</row>
<row label="d4">dqc-subdivision</row>
<row label="d5">dqc-is-duplicate</row>
<row label="d6">dqc-survey-id</row>
<row label="d7">dqc-average-device-score</row>
<row label="d8">dqc-lowest-device-score</row>
<row label="d9">dqc-total-surveys</row>
<row label="d10">dqc-device-failures</row>
<row label="d11">dqc-completion-rate</row>
<row label="d12">dqc-duplication-rate</row>
<row label="d13">dqc-failure-rate</row>
<row label="d14">dqc-qualification-rate</row>
<row label="d15">dqc-last-survey-taken</row>
<row label="d16">dqc-manual-isq-rate</row>
<row label="d17">dqc-automated-isq-rate</row>
<row label="d18">dqc-osq-rate</row>
<row label="d19">dqc-brand-familiarity</row>
<row label="d20">dqc-open-end</row>
<row label="d21">dqc-speeding</row>
<row label="d22">dqc-honey-pot</row>
<row label="d23">dqc-straightlining</row>
<row label="d24">dqc-distinct-supplier-count</row>
</text>
</survey>


Viewing Quality Tools Data in Your Survey Responses​

On your survey, go to the navigation bar and click:

  • RESPONSES → VIEW/EDIT RESPONSES

The data collected by the DQCToolBox will be stored in the dqc_data columns.

You can access this data in your survey responses by clicking on the Choose Columns and add the dqc_data Survey Variable (columns) to view your responses.

Decipher Responses


✅ Summary​

  • Include the initial DQC script after the <survey> tag.
  • Change the API_KEY in the script to your own.
  • Include the final DQC script at the end of the </survey> tag.
  • Confirm success by checking that the data is stored in the dqc_data columns.