Integrate the Code
Add chiasm-tracker.js to your web page and collect your first gaze data.
1. Load the library
Add the script tag to your HTML page:
<script src="https://cdn.chiasm.eu/latest/chiasm-tracker.js"></script>
2. Initialize the tracker
Call initChiasmTracker with your auth token. This returns a tracker object used for all subsequent calls.
const tracker = await initChiasmTracker({
authToken: 'YOUR_AUTH_TOKEN',
});
3. Set experiment info
Register your experiment and participant IDs with setExpInfo so gaze data is associated correctly.
tracker.setExpInfo('YOUR_EXPERIMENT_ID', 'YOUR_PARTICIPANT_ID', true);
4. Calibrate
Run screen calibration followed by tracker setup (webcam access, gaze calibration, and validation):
await tracker.showScreenCalibration();
await tracker.setupTrackerWithRetries();
5. Record gaze data
Wrap your stimulus presentation with startRecording and stopRecording:
await tracker.startRecording();
// ... show your stimulus ...
await tracker.stopRecording();
6. Clean up
Release tracker resources when the experiment is finished:
await tracker.cleanupTracker();
Next Steps
- Custom Code tutorial — full walkthrough for a vanilla JavaScript experiment
- jsPsych tutorial — add tracking to a jsPsych experiment
- Qualtrics tutorial — embed tracking in a Qualtrics survey