IFrame Query API

Use this API to query if there are survey opportunities available for a respondent.

When surveys are available, you can use the provided "offerURL" in the API's output to set as the source of your iFrame or to display it on WebView.

Command

"iframe/query/1"



Inputs

The following values are expected in the JSON body:

Name Type Required Description
command String

Must be "iframe/query/1"

rid String

A string uniquely identifying the respondent. The same string must be sent on repeat visits, allowing us to target using previously collected data.

country String

The 2 digit ISO country code

postalCode String

Australia, South Africa: 4 digits
US, France, Germany, Italy, Mexico, Saudi Arabia, Spain: 5 digits
South Korea, : 6 digits
Brazil: 8 digits
Canada: AnAnAn
Argentina: AnnnnAAA
UK: AAnAnAA, AnAnAA, AnnAA, AnnnAA, AAnnAA, AAnnnA
Other: anything

gender String

Accepted values:

  • 1, m or M for male
  • 2, f or F for female
birthday String

The respondent's birthday, formatted as yyyy-MM-dd

unitConv Integer

The number of units awarded for each US Dollar that we pay you. In the example command below, if we have a survey where the payout to you is $2.50, the respondent would be shown "50 Silver Coins".

ip String

String value corresponding to the respondent's IP. If included, we will use it to consider only the surveys where a respondent with the same IP has not participated, thus reducing the probability of a term due to deduplication.

fingerprint String

The code to compute the fingerprint is available at https://hosting.researchforgood.com/js/df-fp.js
The fingerprint is computed using the following JavaScript:

function processDataForceFingerprint(fingerprint) {
        console.log("Please implement me!, fingerprint = " + fingerprint);
    }
    getDataForceFingerprint(processDataForceFingerprint);
**See description for possible values *

Additional Datapoints

In addition to the above parameters, you may also send us any of the datapoints listed in the RFGdatapoints.json file.
That file contains a JSON document listing all of our basic profiling datapoints, including questions and answer translated into multiple languages. The structure of each datapoint is as follows:

{
    property: "propertyName",		 		//  This is the property to send us
    name: "Human readable name",			//  Ignore
    countries: ["US","CA"],				//  The countries this datapoint applies to
    type: 0, 						//  Indicates single or multi-valued
    question: {						//  The question in many languages
	en-US: "The question in US English",
	es-US: "The question in US Spanish",
	etc...
    }
    answers: [						//  The answers in many languages
        null,						//  Answer #0 is always null
        {						//  The first answer starts with 1
            en-US: "Answer #1 in US English",		//  Answers are provided in many languages
            es-US: "Answer #1 in US Spanish",
            etc...
        },
        {
            en-US: "Answer #2 in US English",
            es-US: "Answer #2 in US Spanish",
            etc...
        },
        {
            en-US: "Answer #3 in US English",
            es-US: "Answer #3 in US Spanish",
            etc...
        },
        etc...
    ]
}

Datapoint Types

Datapoint types may be:

  1. Radio Buttons (single selection). Please send us the property name followed by a single integer indicating the selected answer. E.g. householdIncome: 4
  2. Checkboxes (multiple selection). Please send us the property name followed by an array of integers indicating the selected answers. E.g. ethnicityUS: [1,2,4]
  3. Dropdown (single selection). Please send us the property name followed by a single integer indicating the selected answer. E.g. employmentIndustry: 2

For these optional datapoints, you may provide as few or as many as you wish. Any datapoints not provided will be profiled when the respondent begins to take surveys. Please note that some datapoints only apply to certain countries. If a datapoint does not list countries, then it applies to all countries.


Outputs

Name Type Description
offer String

Indicates if we have surveys available for the respondent. Possible values:

  • yes - We have surveys available
  • no - We do not have surveys available
offerURL String

Only returned if we have surveys available for the respondent. You should use this URL as source of the iframe or WebView where you want to display our surveys.


Example Command

{
    "command": "iframe/query/1", 
    "rid": "4e882a9bc2748d24",
    "country": "US",
    "postalCode": "10025",
    "gender": "m",
    "birthday": "1977-02-25",
    "unitName": "Silver Coins",
    "unitConv": 20,
    "ip":"57.143.126.61",
    "fingerprint":"c042ac342900efdfceee4a2edb549f5c",
    "employees_number":2   //Additional non-mandatory datapoint
}

Example Response

On success, the API will respond as follows:

{
    command: "iframe/query/1",
    result: 0,
    response: {
        offer: "yes",
        offerURL: "http://www.saysoforgood.com/iframe/......"
    }
}

If no surveys are available, the response will be as follows:

{
    command: "iframe/query/1",
    result: 0,
    response: {
        offer: "no"
    }
}