w Docs

Using your own analytics tool

1 min readUpdated November 9, 2026

Every time a visitor picks another language, the plugin fires a cls_language_switched event on the page, just before the browser goes to the new page. Use it to send the switch to any tool:

document.addEventListener( 'cls_language_switched', function ( e ) {
    // e.detail.from: "en", e.detail.to: "fr", e.detail.url: the page they are going to
    if ( window.plausible ) {
        plausible( 'Language Switch', { props: { from: e.detail.from, to: e.detail.to } } );
    }
} );

See Developers โ†’ JavaScript API for details.