Overview

This is an overview of the Fera JavaScript API.

All you really need to have in your store is to use the JS API is the fera footer code installed and your API public key.

Once the Fera footer has been installed, you can access Fera's JS api with the fera tag.

The Recommended Way
Works, But Not Recommended

Before your custom code, add this code to ensure the Fera system hs initialized:

fera = fera || [];

Use the 'push' method to run methods to ensure that your code still runs of Fera initializes after this line is read:

fera.push("setProduct", { id: 'product-123' });

This method of doing it will work in most cases but is susceptible to breaking if the Fera system initializes after your code is ready by the browser.

fera.setProduct({ id: 'product-123' });

When writing code that interacts with the JS api you should always start your code with: fera = fera || []; to ensure that if your code runs before Fera's footer code, Fera doesn't reset the buffer of commands.

By using the .push method for this JS API, you will also be pushing your functions to the fera as if it is a primitive array type. The reason we do this is because if your code runs before the Fera system initializes, Fera will automatically "flush" the commands in the array and run them. This technique is used by all the major companies with JS APIs like Google Analytics as well.