PICKZEN
  • FAQ
  • Security in Pickzen
  • Builder
    • Builder Overview
    • Questions
      • Types and layouts
      • Display settings
      • Styling the text
      • Slide settings
      • Admin names
      • Slide help
      • Feedback slide
      • End slide
        • Number of outcomes
        • Forget results
        • Automatic redirect
        • Recommending content
      • Skip Logic
        • Branching controlled by slides
        • Branching controlled by tree
    • Products
      • Selecting products
      • Managing products
    • Linking
      • Linking choices to products
    • Install
      • Notification
      • Link
      • Button
      • Embedded
    • Lead Generation
      • Lead capture before recommendation
      • Receiving leads by e-mail
      • Sending e-mails to new leads
        • Adding customized data to e-mails
    • Advanced
      • Product attributes
      • Features table
        • Features from linking
        • Features from attributes
        • Smart texts
      • Insertable texts
        • User answers
        • Response based texts
      • Slots
  • Analytics
    • A/B Tests
      • Launching an A/B Test
      • Reviewing A/B test results
    • Insight panel
      • Overview
      • Responses
      • Leads
    • Parameters tracking
    • Sales tracking
  • Integrations
    • Your website
      • Pickzen Code
        • Installing the Pickzen Code in Shopify
        • Installing the Pickzen Code on any website
      • Add to cart
      • Add all to cart
    • MailChimp
    • Klaviyo
    • HubSpot
    • Zapier
    • Recharge
      • Recharge v1
      • Recharge v2
    • Product Feeds
    • Google Analytics
    • Facebook
  • Guides
    • Facebook/Instagram retargeting
    • HubSpot guide
    • MailChimp guide
    • Klaviyo guide
    • No-Code
      • Builder
        • Aliases
        • Tables
          • Executable tables
          • Data tables
          • Cell types
        • Settings
        • Simulation
      • Functions
        • ADDTO
        • CONCAT
        • EMPTY
        • EVALTABLE
        • EXTRACT
        • FIRST
        • FLAT
        • LOG
        • NTH
        • PERSONALITY
        • PRESCRIBE
        • PRESCRIBESLOTS
        • PROPERTY
        • RANK
        • RECIDS
        • RECGROUP
        • RECSKUS
        • REFINE
        • REMOVEFROM
        • SECOND
        • SLOTS
        • SPLIT
        • TABLEVALUE
        • TRUNC
      • Tutorials
        • Prescription Rules + Taglines
        • Calculator
  • Design System
    • Enabling the DS
    • The builder
      • Preview panel
      • Components panel
      • Properties panel
    • Properties
    • Variants
    • Properties values
      • Parametrization
      • References
      • Deferred actions
    • Components
      • [Base]
      • Button
      • Collapsable
      • Container
      • CoverSlide
      • Deck
      • Dropdown
      • EndFormSlide
      • EndSlide
      • FeedbackSlide
      • FormMapper
      • FormSlide
      • Grid
      • HTML
      • Icon
      • Image
      • InputDate
      • InputNumber
      • InputText
      • Label
      • Link
      • Product
      • ProgressBar
      • QuestionSlide
      • Repeater
      • Separator
      • SlideRenderer
      • Specs
      • TextArea
    • Views
    • Editor settings
    • Accesibility
    • Interceptors
    • HowTo
      • Show a variant programmatically
      • Use CSS in custom component
  • Administration
    • Managing accounts
      • Inviting collaborators
      • Requesting access
    • Copying pickzens between accounts
    • Replacing pickzens
    • Recovering versions
  • Developers
    • Developers panel
      • CSS customization
      • JavaScript customization
    • JavaScript API
      • Hooks
      • HOWTOs
        • How to add results
        • How to get the answers
        • How to decorate products
        • Escaping the iframe
    • REST API
      • API rate limit
      • Assistants resource
      • Responses resource
    • SDK
      • Documentation
        • Engine
        • Slide
        • CoverSlide
        • QuestionSlide
          • QuestionOption
        • FeedbackSlide
        • FormSlide
          • FormField
            • SelectorField
            • SelectorFieldOption
            • ImageField
        • EndSlide
          • Result
      • HOWTOs
        • Populate custom dropdown
Powered by GitBook
On this page
  1. Developers
  2. SDK
  3. Documentation

Engine

/**
 * Loads and intializes the Pickzen engine
 * @param code Quiz code
 * @param server Pickzen server (https://admin.pickzen.com by default)
 * @param config Map to overwrite default settings
 * @returns {Promise}
 */
load(code, server, config={}, preview, preload) 

/**
 * Return the quiz state
 * @returns
 *  'init' Initializing the quiz, for example while some asynchronous requests are called to fetch initial state data
 *  'start' Cover slide
 *  'doing' Question slides (informative, filter, feedback, etc.)
 *  'help' Help slide
 *  'end' End slide (Recommendation slide for example)
 */
getState()

/**
 * Returns true if the current state is the state provided
 * @param stateId
 * @returns {boolean}
 */
inState(stateId)

/**
 * Get the current slide type
 * @returns {string}
 *  'cover' Cover slide
 *  'info' Informative slide
 *  'filter' Filter slide
 *  'form' Form slide
 *  'end' End slide (Recommendation slide for example)
 */
getSlideType()

/**
 * Return the current slide object
 *
 * @returns {FormSlide|EndSlide|QuestionSlide|CoverSlide|FeedbackSlide}
 */
getSlide()

/**
 * Returns true if the quiz has a cover slide
 * @returns {boolean}
 */
hasCoverSlide()

/**
 * Return the cover slide object
 *
 * @returns {CoverSlide}
 */
getCoverSlide()

/**
 * Return the end slide object
 *
 * @returns {EndSlide}
 */
getEndSlide() 

/**
 * Returns true if the quiz is completed: The recommendations slide is being displayed.
 *
 * @returns {boolean}
 */
isFinished()

/**
 * Return true if we can go to the next slide.
 * For example, in case of a slide with mandatory question, we can only go to the next slide when an answer is selected.
 *
 * @returns {boolean}
 */
canNext()

/**
 * Return true if we can go back to the previous slide.
 * For example, we can't go back before the first slide.
 *
 * @returns {boolean}
 */
canBack() 

/**
 * Return true if we can skip the current slide.
 * For example, a slide with mandatory answers can't be skipped.
 *
 * @returns {boolean}
 */
canSkip() 

/**
 * Returns a flat array with the IDs of the selected options (answers)
 *
 * @param onlyToFilter If true, only the options of filter type slides will be returned.
 * @returns {[]}
 */
getSelectedOptionIds(onlyToFilter)

/**
 * Returns the results that mactch with the current selected options.
 *
 * @returns {Promise}
 */
getPartialResults() 

/**
 *
 */
getDatasheets(dsIds)

/**
 * Returns the progress of the quiz
 *
 * @param includeCover If true, take into account the cover slide to calculate the progress
 * @param startAtZero If true, the current slide will be taken into account when the slide is displayed. otherwise, it will only by taken into account when the slide is passed.
 * @returns {number}
 */
getProgress(includeCover=false, startAtZero=true) 

/**
 * TODO
 */
getProgressBar()

/**
 * TODO
 */
getStep()

/**
 * Returns a quiz setting.
 *
 * @param param Id of the setting.
 * @returns {*}
 *
 * @deprecated use getSetting
 */
getConfig(param)

/**
 * Returns a quiz setting.
 *
 * @param param Id of the setting.
 * @returns {*}
 */
getSetting(key) 

/**
 * TODO
 */
getThemeSetting(key) 

/**
 * Returns the selected option IDs for the provided slideId.
 *
 * @param slideId
 * @returns {[]}
 */
getSelection(slideId)

/**
 * Returns the form field value for the provided fieldId.
 *
 * @param fieldId
 * @returns {*}
 */
getFormAnswer(fieldId)

/**
 * Returns true if the provided optionId has been selected.
 * @param optionId
 * @returns {*|boolean}
 */
isSelectedOption(optionId)

/**
 * Sets a global value that will reach the backend. It can be used to add additional data to a generated lead for example.
 *
 * @param id
 * @param value
 */
setGlobalValue(id, value)

/**
 * Returns a global value.
 * @param id
 * @returns {*}
 */
getGlobalValue(id)

/**
 * Sets a session value that won't reach the server.
 * @param id
 * @param value
 */
setSessionValue(id, value) 

/**
 * Returns a session value.
 * @param id
 * @returns {*}
 */
getSessionValue(id)

/**
 * Prevents the provided slides to be displayed.
 *
 * @param slideIds Array with the slide Ids.
 */
avoidSlides(slideIds)

/**
 * Allows the provided slides, avoided previously, to be displayed.
 *
 * @param slideIds
 */
allowSlides(slideIds)

/**
 * Clear the responses and results from a previously taken quiz, so the user sees a fresh new quiz.
 */
clearStoredResults()

/**
 * Bypass the default branching logic to show as next slide, the provided slide.
 *
 * @param slideId
 */
forceNextSlide(slideId) 

/**
 * Indicates that a slide have not to be stored in the session historic, so it won't appear when going backwards.
 * Its data also won't be sent to the server.
 *
 * It can be called before or after the slide is displayed.
 *
 * @param slideId
 */
noHistory(slideId) 

/**
 * It allows to show again a slide previously dispayed.
 *
 * @param slideId
 */
allowReask(slideId)

/**
 * Returns true if the quiz has been reloaded. For example, when the user restart a completed quiz at another time.
 *
 * @returns {*}
 */
isReloaded() 

/**
 * Returns the current user Id. The user Id is persistent, so the user will have always the same id, unless the browser history is cleared.
 * @returns {id}
 */
getUserId() 

/**
 * Send information to the server indicating a dropoff has ocurred.
 */
dropOff() 

/**
 * Prepopulates form fields
 *
 * @param fields {id:value}. For example: [{101:'John', 102:'john@pickzen.com'}]
 */
prepopulateFields(fields) 

/**
 * Returns the Id that will identify this user's responses.
 *
 * Whenever the user restarts or goes back from the end slide, a new Id will be generated.
 *
 * @returns string
 */
getCurrentResponsesId() 

/**
 * Sets a key value into the sandboxed localstorage
 */
setLocalStorageItem(key, value) 

/**
 * Removes a key from the sandboxed localstorage
 */
removeLocalStorageItem(key) 

/**
 * Returns a key value from the sandboxed localstorage 
 */
getLocalStorageItem(key, defaultValue) 

/**
 * Returns the assistant code
 */
getCode() 

/**
 * Interpolates a text changing its parameters
 */
interpolate(text) 

/**
 * Registers a new field validator
 */
addValidator(validatorId, fn) 

/**
 * Makes an HTTP GET request
 */
httpGet(url) 

/**
 * Makes an HTTP POST request
 */
httpPost(url, payload) 

/**
 * Uploads a file into the user account
 */
httpUpload(url, file, type, filePath, policy, isPublic, signature, credential, expiration) 



PreviousDocumentationNextSlide

Last updated 4 years ago