How to use the javascript API

The object

You can always run the Symplify object in the console to get a list of JS API functionality.

sitegainer // Returns list of functions

 

sitegainer.newPage

If you are using single-page apps with libraries like react.js and node.js or for any other reason want to run Symplify dynamically, you can just run sitegainer.newPage();. This runs the same functionality as is run when the page loads. It also cleans your DOM from any changes that Symplify had run before sitegainer.newPage(); is called.

sitegainer.newPage(); // Simulate a pageload

What happens:

1. Dynamically refreshes DOM from Symplify changes ( no reload and no effect on javascript binds )
2. Updates information about URL, user, DOM.
3. Checks Audience for each active project based on updated information
4. Runs projects where Audience is true
5. Sends pageview and events to Symplify and integrations

 

sitegainer.runProject([The project ID])

Run’s a specific project regardless if Audience is true or not.

sitegainer.runProject('19191919') // Runs a specific project.

 

sitegainer.getActiveVariation([The project ID])

Get’s the active variation for a project. Useful for retrieving active variation after using sitegainer.runProject();.

sitegainer.getActiveVariation('19191919') // Runs a specific project.
Was this article helpful?
0 out of 0 found this helpful