<script>
// Keep track of the current session
let session = null;
// Forward pagent "conversion" events to the JENTIS data layer
window.addEventListener('pagent:event', (e) => {
const event = e.detail;
// Store the session start event in case we are running an experiment
if (event.kind === 'session_start' && event.experiment_id) {
session = event;
return;
}
// Only track conversions for active experiments
if (!session || event.kind !== "conversion") return;
// Prepare the JENTIS queue (it as a simple array on window)
window._jts = window._jts || [];
// Push the event object itself
_jts.push({
track: 'event', // JENTIS track command
group: 'generic', // optional grouping
context: 'pagent', // helps to identify the source
kind: 'conversion', // helps to identify the event type
experiment_id: session.experiment_id, // unique identifier of the experiment
variation_id: session.variation_id, // unique identifier of the variation
cohort_id: session.cohort_id, // unique identifier of the cohort
is_control: session.is_control // whether the displayed variation is control
});
// Finally submit everything to JENTIS
_jts.push({ track: 'submit' });
});
</script>