Is there a way to set up a listener function to listen to events?

You can easily listen to Journeys lifecycle events by registering listener functions like so:

javascript var listener = function(event, data) { console.log(event, data); } // Specify an event to listen for branch.addListener('willShowJourney', listener); // Listen for all events branch.addListener(listener);

Listener NameDescription
willShowJourneyJourney is about to be shown
didShowJourneyJourney's entrance animation has completed and it is being shown to the user
willNotShowJourneyJourney will not be shown and no other events will be emitted
didClickJourneyCTAUser clicked on Journey's CTA button
didClickJourneyCloseUser clicked on Journey's close button
willCloseJourneyJourney close animation has started
didCloseJourneyJourney's close animation has completed and it is no longer visible to the user