Opticks Sensor JS response event
The Sensor JS will emit an opticksEvent event when it has finished processing the visit. You can listen for the event with the following code:
<script>
window.addEventListener('opticksEvent', function (event) {
opticksId = event.detail.opticksClickId;
}, true);
</script>
Response format
The response allows you to receive detailed information about the click, including Opticks id to report conversion events, and booleans to indicate whether the click must be prevented or not. Fields not listed in this example are not applicable, and are only used by the Opticks JS sensor internal mechanisms.
{
"opticksClickId": "track_20250404134412_0a2cf15d_672b_43bb_a82a_4f5685ba5778",
"s": "672b43bba82a4f5667efe22c0a2cf15d85ba5778",
"p": true,
"r": false
}
Each parameter is explained below:
Parameter | Description |
---|---|
opticksClickId | Opticks unique click id. This id can be used to obtain information from that individual click in the Opticks platform and can be used to report a conversion event. |
s | Opticks session id. Used to identify all clicks for the same user. Session expires after 30 minutes of inactivity. It can also be used to report a conversion event. |
p | True or false. Indicates whether the click is considered high risk according to the Sensor security configuration and the analysis. |
r | True or false. Indicates whether the click is blocked according to the Sensor security configuration and the analysis. Traffic control module must be enabled to receive positive responses, otherwise will always be false. |
Implementation example
The Opticks response event can be used for several custom actions such as enriching forms or blocking actions among many other business cases.
For example, given a form with the following fields:
<input type="hidden" id="opticksId" name="opticksId" value="empty">
<input type="submit" id="submitButton" disabled="true" value="Send">
The Submit button could be disabled by default, and activated once the the analysis has finished and the user should be allowed implementing the Opticks event like this:
<script>
window.addEventListener('opticksEvent', function (event) {
var opticksId = event.detail.opticksClickId;
var highRisk = event.detail.p;
console.log('is click high risk? ' + highRisk);
if (!highRisk) {
document.getElementById("submitButton").disabled = false;
}
document.getElementById("opticksId").value = opticksId;
}, true);
</script>
Analysis information in Sensor JS response event
Opticks can also provide full analysis information in the Sensor JS response event. This analysis contains all the detections triggered by a visit among other information, and it is encrypted using a shared secret key between the customer and Opticks, so it needs to be decrypted server side. This is disabled by default, but can be enabled if requested. Please send an email to support@optickssecurity.com if you are interested in this feature.