The widgets can be installed through our CDN or npm. Usage through the CDN will maintain backwards compatibility, while the npm library will use semantic versioning.
Depending on the use-case, different IDs are required to use the widgets.
- Single assessment
- assessmentID
- Assessment(s) associated with a recommendation
- benchmarkID or packageID
- profileID
Additionally an authKey
is required.
<script src="https://cdn.traitify.com/js/v3/traitify.js"></script>
<script>
Traitify.http.authKey = "Your Traitify public key";
Traitify.http.host = "https://api.traitify.com";
Traitify.options.assessmentID = "an assessment id you have generated via a server side client";
Traitify.render("#the-id-of-the-target-you-wish-to-render-to");
</script>
npm i --save traitify-widgets
import traitify from "traitify-widgets";
traitify.options.assessmentID = "an assessment id you have generated via a server side client";
traitify.render("#the-id-of-the-target-you-wish-to-render-to");
Click here to view other classes available to import, such as Http
.
Click here to view available to components, such as the Results.Personality.Type.List
.
Traitify.render({Survey: "#dom-id"}); // Render just the Survey in the target element
Traitify.render({Results: "#dom-id"}); // Render just the Results in the target element
This is useful if you want to get the career results server side and modify the data returned or just want to proxy through your own server.
Traitify.options.career.path = "/my-career-endpoint";
Traitify.options.career.experienceLevels = [4, 5];
Traitify.options.career.perPage = 10;
Traitify.options.career.jobs = {
inline: true, // Show the jobs in the list view, otherwise show them in the modal
path: ({career}) => career && `/my-jobs-endpoint?careerID=${career.id}`, // Can be a string or function
source: "Indeed" // If no jobs are found, a link displays to Indeed, Monster, or MyNextMove
};
Traitify.render({
"Survey": "#survey",
"Results": "#results",
"Results.Career.Container": "#careers",
"Results.Guide": "#guide",
"Results.Personality.Type.List": "#personality-types",
"Results.Personality.Trait.List": "#personality-traits"
});
- Components used directly must be wrapped by a Container component
- The Container can wrap multiple components
- Container accepts these props
- assessmentID
- authKey
- benchmarkID
- graphql
- host
- locale
- options
- packageID
- profileID
- version
- If you've set options in a Traitify instance, pass them as props to the Container
import traitify, {Components} from "traitify-widgets";
export default function Personality({id}) {
return (
<Components.Container {...traitify.props} assessmentID={id}>
<Components.Results />
</Components.Container>
);
}
- Most components trigger an initialized and updated event
- Event handlers must be set before the render command or they will not be called
- Some events may fire multiple times, once for each target specified (such as the Survey and Results)
The widgets are capable of showing multiple kinds of surveys to users in order to satisfy benchmark requirements. To handle the event when all surveys have been finished you should use this event:
Traitify.listener.on("Surveys.finished", (surveys) => {
console.log("Surveys.finished", surveys);
});
To handle the event when each survey has been finished, maybe to record total progress in a backend system:
Traitify.listener.on("Survey.finished", ({response}) => {
console.log("Survey.finished", response);
});
Here are some other events that can be handled:
Traitify.listener.on("Survey.initialized", () => {
console.log("Survey.initialized");
});
Traitify.listener.on("Survey.updated", () => {
console.log("Survey.updated");
});
Traitify.listener.on("Survey.updateSlide", ({response}) => {
console.log("Survey.updateSlide", response);
});
Traitify.options.locale = "en-us";
// Or if the component has already been rendered
Traitify.updateLocale("en-us");
Here is a list of the available locales (en-us
is the default):
- Chinese -
zh-cn
- Creole -
ht-us
- Dutch -
nl-nl
- English (GB) -
en-gb
- English (United States) -
en-us
- French (Canadian) -
fr-ca
- French (France) -
fr-fr
- Japanese -
ja-jp
- Norwegian -
no-no
- Portuguese -
pt-br
- Spanish (United States) -
es-us
- Swedish -
sv-se
Traitify.options.survey.allowBack = true;
Traitify.options.survey.allowFullscreen = true;
Traitify.options.showHeaders = true;
Traitify.options.results.benchmarkID = benchmarkID;
Note: This differs from options.benchmarkID
. A profileID
and benchmarkID
can be used to get an assessment with multiple recommendations. This option can be used to select one of those recommendations.
Traitify.options.perspective = "firstPerson";
OR
Traitify.options.perspective = "thirdPerson";
Traitify.options.survey.disableTimeLimit = true;
Traitify.options.report = "manager";
This report also makes use of a benchmark/recommendation. It will default to the benchmark used to create an assessment. To use a different benchmark, you can pass the ID as an option.
Traitify.options.benchmarkID = benchmarkID;
Traitify.options.report = "candidate";
Traitify.options.report = "employee";
We expose our JavaScript api client that you can use to make additional calls to our API from the client side. We make available get
, put
, and post
functions. These methods will use the api key and url you configured when you initialized the Traitify library. Here is an example that returns career matches for a career-deck
assessment. Further documentation on the API methods available can be found at https://app.traitify.com/developer/documentation.
<script src="https://cdn.traitify.com/js/v3/traitify.js"></script>
<script>
Traitify.http.authKey = "Your Traitify public key";
Traitify.http.host = "https://api.traitify.com";
const assessmentID = "an assessment id you have generated via a server side client";
Traitify.http.get(`/assessments/${assessmentID}/matches/careers`).then((matches) => {
console.log(matches);
});
</script>
npm install
npm run dev
npm run build
- React: https://reactjs.org
- Webpack: https://webpack.github.io