All Collections
Integrations
Exporting Mutiny data
Custom Mutiny Data Integrations (Javascript)
Custom Mutiny Data Integrations (Javascript)

Mutiny exposes user and experience variables in the frontend so you can sync Mutiny experience information with your backend database

Updated over a week ago

When the Mutiny client attaches to your webpage, it exposes variables that can be used to send custom analytics events to your backend data sources. 

The window.mutiny  object contains information about the segments and experiences running on the page, as well as the current visitor. 

The experiences  attribute contains an array of all active experiences the visitor is currently seeing and relevant context such as:

  • audienceSegment  - the Segment you define in Mutiny associated with the experience

  • impressionType - either "personalized" or "control"

  • page - the current page URL

  • variationName - the name of the variant if you are running a multi-variant experience

The visitor attribute contains information that Mutiny uses to segment the user, including their unique token which persists between sessions. 


Here is an example of the array returned by window.mutiny 

Mutiny also exposes this same experience data on a mutiny:experience-impressions event listener on the window variable, which gets triggered every time an experience is rendered for the visitor.

To send this information into your own database or other platforms, you will need to write custom Javascript to read these variables and send them to the appropriate destination.

For the most accurate tracking, we recommend calling both the window.mutiny object, as well as attaching an event listener in your code. This will ensure data is being passed for any window changes, as well as single page applications. Here is an example of JavaScript to have your developer implement:

if (window.mutiny.experiences) {
window.mutiny.experiences.forEach(function(experience) {
// replace this with reporting code
console.log(experience.variationName);
});
}
window.addEventListener('mutiny:experience-impression', function(event) {
// replace this with your reporting code
console.log(event.detail.variationName);
});

Be sure to replace console.log with the appropriate code to pass this data back to your reporting platform. Additionally, be sure to replace variationName with whatever attribute(s) are relevant to you.


Implementation questions?

If you have any questions, please feel free to reach out through intercom chat or by contacting mutinylovesyou@mutinyhq.com

Did this answer your question?