Get a list of the JS API functions
Enter symplify and hit Enter in the console to get a list of JS API functionality.
symplify // Returns list of functions
debug()
If you turn on debug mode Symplify will output complete logs and objects in the console
symplify.debug(1); // Turn on debug mode
symplify.debug(0); // Turn off debug mode
getActivatedProjects()
Get's an array of active projects.
symplify.getActivatedProjects();
getActiveVariations()
Get's the active variation for a project. Useful for retrieving active variation after using symplify.runProject();.
symplify.getActiveVariations([The project ID]);
getCTMData()
Get's data that would be sent to CallTrackingMetrics if implemented.
getGeo()
In order to retrieve the visitors IP address or geodata, just use this simple snippet:
symplify.getGeo([key]); // Enter a key to get the value
Example keys and values (keys in bold):
as:"AS2119 Telenor Norge AS"
city:"Stockholm"
country:"Sweden"
countryCode:"US"
isp:"Bredbandsbolaget AB"
lat:59.3333
lon:18.05
org:"Bredbandsbolaget AB"
query:"213.115.103.83"
region:"AB"
regionName:"Stockholm"
status:"success"
timezone:"Europe/Stockholm"
zip:"173 11"
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 symplify.newPage();. This runs the same functionality that is run on page loads. It also cleans your DOM from any changes that Symplify had run before symplify.newPage(); is called.
symplify.newPage();
What happens:
1. Updates information about URL, user, DOM.
2. Checks audience for each active project based on updated information
3. Runs projects where the Audience is true
4. Sends pageview and events to Symplify and integrations
optOut()
If you need to temporarily prevent Symplify from running projects you can use our function below to opt-out. You can also add ?sg_optout ( or #sg_optout / &sg_optout ) in the URL and hit Enter. This will load the page without Symplify.
This sets a session cookie that will be removed when the tab and/or browser is closed. You can also remove the sg_optout cookie to exit this mode.
symplify.optout(1); // Turn on optout
pushGoal()
Push goals can be used to fire a goal from your own code. This can be useful if you can't set up your statement with the Goal audience. What you need to do is to add a push goal in your goals for the project and then copy the generated snippet and run that callback from your own code whenever the goal is to be registered.
if(symplify) {
symplify.pushGoal("{You goal id}");
} else {
document.addEventListener("symplify-loaded", function(e) {
symplify.pushGoal("{You goal id}");
});
}
revenue()
See How to track visitors e-commerce transactions