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
  • API
  • Injected variables
  1. Developers

JavaScript API

API

From the customized API JavaScript, you can call some API functions to control the behavior of the Assistant. All these functions have to be called from the Extension object, for example:

var selectedOptionID = Extension.getSelectionId(3, history);

The available API functions for public use are:

getSelectionId(slideId, history)

Returns the ID of the selected slide answer. Only for single selection slides.

getSlide(slideId, slides)

Returns the slide with the indicated ID.

getOptionId(slideId, index, slides)

Returns the answer ID from its answer index (0..n).

getFormResponse(slideId, slides, fieldId, history)

Returns the user field response from field ID.

isSelectedOption(optionId, slides, history)

Returns true if the optionId was selected.

getSelectionIndex(slideId, history, slides)

Returns the index of the slide selected answer (0..n).

setFinalizer(extension, fn)

Code that will be executed when the slide is destroyed.

setHook(extension, id, fn)

Code that will be executed before the hook with that ID is executed.

setGlobalValue(id, value)

Sets a global value that can be used to generate customized emails.

getGlobalValue(id)

Gets a global value previously set though setSessionValue.

setSessionValue(id, value)

Sets a value in memory that can be shared between slides. It’s used for programmatic control.

getSessionValue(id)

Gets a value previously set though setSessionValue.

getRequest(url, callback)

Makes a GET request. The callback function will be executed passing the response as a parameter.

postRequest(url, contentType, data, callback)

Makes a POST request. The callback function will be executed passing the response as a parameter.

Valid contentTypes: json, form, text.

getCurrentSlideState()

Gets the current slide state. For example, to get a value from within a defined hook.

contains(item,list)

Returns true if the item is in the list.

containsAny(list1, list2)

Returns true if any alement of list1 is in list2.

containsAll(list1, list2)

Returns true if all elements of list1 are in list2.

getParameterByName(name, url)

Returns the specified query parameter from the URL.

getByKey(list, key, value)

Finds an element in the list whose key value is specified.

getIndexByKey(list, key, value)

Returns the index of the element in the list whose key value is specified.

executeJS(fn, callback, async, params)

Executes a JavaScript function in the iframe holder page.

  • code: Name of the JavaScript function

  • callback: Function to be executed when the call is completed. This parameter is only needed in the case of an asynchronous call.

  • async: true if the call is asynchronous, false otherwise.

  • params: Array of parameters to be passed to the function.

Some API functions need special parameters such as extension, slides, or history. These variables are available in the context and can be used to call the API.

Injected variables

Pickzen will automatically inject some variables that can be used in the JavaScript sections to customize the functionality of each slide:

  • slide: It will include the current slide definition: title, options, etc.

  • slides: It will contain an array with all slides' definitions.

  • history: It will contain the previous slide responses so far.

PreviousJavaScript customizationNextHooks

Last updated 3 years ago