JavaScript-Triggered Session Recordings

JavaScript-Triggered Session Recordings let you control exactly when a session recording begins by starting it through code. Instead of recording every visit or relying on page-based rules, recordings start only when your site explicitly triggers them.

This is ideal for recording high-intent behavior, dynamic flows, and single-page applications (SPAs).

How It Works

When enabled, Crazy Egg does not automatically record sessions.

A recording starts only when your site runs the following JavaScript:

(window.CE_API || (window.CE_API=[])).push(function(){ 
CE2.startRecording();
});

Until this runs, no recording is created.

When to Use This

Use JavaScript-Triggered Recordings if you want to:

  • Start recording after a specific user action
  • Control recording in SPAs or dynamic routes
  • Avoid recording low-value or irrelevant traffic
  • Coordinate recording with login, consent, or funnel entry

How to Set It Up

  1. Go to Recordings → Customize Recordings
  2. Under What should we record select Start recording sessions when triggered via JavaScript
  3. Add the following code at the point where you want the recording to begin:

(window.CE_API || (window.CE_API=[])).push(function(){
CE2.startRecording();
});

Once this code runs, the current session begins recording immediately.

Important Placement Notes

The trigger must run:

  • After the Crazy Egg base script has loaded
  • At the exact moment you want recording to start

Common placements include:

  • After a button click or form interaction
  • After a route change in an SPA
  • After login or consent confirmation
  • Via Google Tag Manager (Custom HTML tag)

Troubleshooting

If recordings are not starting, check the following:

1. Crazy Egg script is missing
The trigger does not load Crazy Egg. The base script must already be on the page.

2. Trigger fires too early (common in SPAs)
Ensure the trigger runs after Crazy Egg initializes and after the relevant route or user action completes.

Was this article helpful?

Related Articles

Need Support?

Can’t find the answer you’re looking for? Don’t worry we’re here to help!

Submit a request