This document will walk you through the methods of the pathfora class that will be used to help you deploy your modules. The rest of the SDK documentation will walk you through how to customize your module's configuration, and provide code examples to show you these methods in context.

initializeWidgets

This method is used to initialize any modules built with Pathfora. It kicks off all the heavy lifting that needs to be done to render the modules on the page based on their configuration settings.

initializeWidgets function
Parameter Type Behavior
modules array or targetting object list of modules to initilize on the page
config object optional generalized configuration settings for multiple modules
options object optional additional options for the initialization (see below)
options object
Key Type Behavior
priority string if set to "ordered" will only show the first valid module from the list initialized

Type Configuration Methods

Each module type that Pathfora supports has its own configuration method, which accepts a single object as a parameter. This object should include the configuration settings for the module, the following keys are common across all module configuration types.

type configuration object
Parameter Type Behavior
id string required unique id for the module, no two modules can have the same id
msg string text message content, often contained in a paragraph tag in the module
headline string header or title text for the module, not supported by some layouts
footerText string text footer content, not supported by some layouts

We cover each of these type configuration methods and their parameters in individual type sections below.

initializeABTesting

This method is used to initialize A/B Tests modules. If you're creating an A/B test scenario this should always be called before the initializeWidgets method.

initializeABTesting function
Parameter Type Behavior
abTests array list of A/B test config objects to initialize

A/B Test Configuration Method

A/B Tests have their own configuration method ABTest. We cover this configuration in detail in the A/B Testing section of this documentation.

recommendContent

recommendContent is a public method that makes a request to the Lytics content recommendation API and returns a list of recommended documents for the user. These results are also placed in session storage to reduce the number of calls to the API on subsequent page loads.

Note: Lytics' public recommendation API is only authorized for use on domains that have been whitelisted for your account. Contact your customer success representative success@lytics.io if you need to whitelist a new domain.

initializeWidgets function
Parameter Type Behavior
accountId string id of the Lytics account to make API requests to
params object object containing query params to call the recommendation API with
id string "unique identifier" for the recommendation, used to reaccess response data from session storage
callback function function to execute once we've received a response from the API. This function is passed the document objects in an array

triggerWidgets

triggerWidgets is a helper method for widgets with the manualTrigger displayCondition. Widgets with this condition will not display until all other display conditions are met, and pathfora.triggerWidgets has been called. This method is similar to initializeWidgets, in that it is useful when you want to trigger a module on a custom event with JavaScript. However with triggerWidgets you don't need to pass in widget object thus you can call this method even before the config has been defined.

initializeWidgets function
Parameter Type Behavior
widgetIds array optional list of ids of widgets to display, if empty this method will trigger all widgets with the manualTrigger displayCondition