JavaScript API

The Command Queue

The tracking script exposes a command queue via window._conv_q. You can push commands to this queue before or after the script loads — commands pushed before the script loads are processed once it initialises.

// Always initialise safely
window._conv_q = window._conv_q || [];

// Push a command
window._conv_q.push({
  what: 'methodName',
  params: { key: 'value' }
});

Important: Always use window._conv_q = window._conv_q || [] — never assign an empty array directly, as this overwrites any commands already in the queue.

Command Format

Commands can use the modern object format or the legacy array format:

// Modern (recommended)
window._conv_q.push({ what: 'identify', params: { visitorId: 'abc123' } });

// Legacy
window._conv_q.push(['identify', { visitorId: 'abc123' }]);

Available Commands

Visitor Identification

CommandDescriptionParameters
identifySet a custom visitor ID (BYOID){ visitorId: string }

Consent Management

CommandDescriptionParameters
consentRequiredBlock tracking until consent is given{ runExperiences?: boolean } (default: true)
consentGivenSignal that consent has been given — flushes queued events and re-runs the script

When runExperiences is false, both experiments and data collection are blocked until consent. When true (default), experiments display immediately but data collection waits.

Experience Control

CommandDescriptionParameters
runRe-run the full evaluation cycle
assignVariationProgrammatically decide a variation{ experienceId, variationId }
triggerExperienceVariationForce a specific variation (testing){ experienceId, variationId }
executeExperienceManually run a specific experience{ experienceId }
disableExperienceDisable a specific experience{ experienceId }
enableExperienceRe-enable a disabled experience{ experienceId }
disableVariationDisable a specific variation{ experienceId, variationId }
enableVariationRe-enable a disabled variation{ experienceId, variationId }
doNotRunExperiencesDisable all experience processing
checkExperiencesRe-evaluate deferred experiences

Goal Tracking

CommandDescriptionParameters
triggerConversionManually trigger a goal{ goalId, experienceId? }
triggerConversionsTrigger multiple goalsSame as triggerConversion
sendRevenueTrack a revenue transaction{ goalId?, transactionId, amount, productsCount? }
pushRevenueAlternative revenue tracking{ amount, productsCount?, goalId?, transactionId? }
recheckGoalsRe-evaluate all goals

Segments

CommandDescriptionParameters
placeVisitorIntoSegmentManually place visitor into a segment{ segmentId }
checkSegmentsRe-evaluate segments that were waiting for data

Location Triggers

CommandDescriptionParameters
triggerLocationManually activate a location trigger{ locationId }

Configuration

CommandDescriptionParameters
setParametersSet tracking script parameters{ delayContinuousActivation?, throttleChanges?, interceptEventsEarly? }
setIntegrationVariableSet a custom variable for targeting{ key, value }
showBodyForce-remove the anti-flicker overlay

Navigation

CommandDescriptionParameters
refreshReload the current page (for split URL original)
redirectNavigate to a URL (for split URL variation){ url: string }

Events

CommandDescriptionParameters
addListenerListen for lifecycle events{ event, handler }
readyCallback when the script has initialisedfunction

Lifecycle Events

You can listen for events fired during the tracking script's lifecycle:

window._conv_q = window._conv_q || [];
window._conv_q.push({
  what: 'addListener',
  params: {
    event: 'experience.activated',
    handler: function(data) {
      console.log('Experience activated:', data.experienceId, data.variationId);
    }
  }
});

Available Events

EventDescriptionData
snippet.initializedScript started
snippet.segments_evaluatedSegments processed{ visitorId }
snippet.experiences_evaluatedExperiences processed
snippet.goals_evaluatedGoals processed
experience.activatedExperience shown to visitor{ experienceId, variationId }
experience.variation_decidedVariation selected{ experienceId, variationId }
goal.triggeredGoal conversion recorded{ goalId }
location.activatedLocation trigger matched{ locationId }
location.deactivatedLocation trigger unmatched{ locationId }
url.changedSPA navigation detected{ from, to }
render.completePage shown (anti-flicker removed)

Timing: Listeners must be registered before the script processes them — either before the script loads, or from Global JavaScript. Listeners added after the script initialises will miss events that already fired.