API Reference

User variables & answers

Insert as {user_answer}, {utm_tag} in any text fields in any place

JS in field values

Use functions like this in text fields, and only this JS

function (answers) {
 if (answers.satisfaction) {
 	if (answers.satisfaction.indexOf('Yes, I want') > -1) {
  	return 'Your are happy'
  }
   if (answers.satisfaction.indexOf('No, I have') > -1) {
  	return 'Your are NOT happy'
  }
 }
  
  return 'Your skin is OK'
}

JS in Screens logic

Use in "JS condition" fields

function (answers) {
 if (answers.satisfaction) {
 	if (answers.satisfaction.indexOf('Yes, I want') > -1) {
  	return 'question-1';
   }
   
   if (answers.satisfaction.indexOf('No, I have') > -1) {
  	return 'products';
   }
 }
  return 'shape';
}

Listening for Events and Sending custom events

AnalyticsManager.on('Subscribe', function(event){
// event.currency = "AUD"
// event.eventID = "781d5918-4915-450e-9da9-bcfaaee39dfd_Subscribe_34473_0"
// event.value = 29.99

// Also you have an access to 
// window.subscriptions 
// It contains an array of user's subscriptions
}) 

Sending events to internal and external analytics

AnalyticsManager.logEvent('EventName', {value: 123})

Saving user properties

AnalyticsManager.setUserProperty('my_property', 'value')

// After that you can access properties from
window.user_properties.my_property
// or as argument in function
function(answers){
  if (answers.my_property && answers.my_property.includes('answer')) {
  	return 'has answer';
  }
}

Navigating between screens

screensManager.moveToNextScreen();

screensManager.moveToSection('screen_id');

screensManager.moveToPreviousScreen();

Detect if a user has PayPal susbcripton

let isHasPayPalSubscroption = !!subscriptions.filter(function(el){return el.payment_system_label == 'PayPal'}).length;