Getting started

Aikey's Javascript SDK is an easy an intutive way of implementing advanced personalisation functionality. You can register events from your users to feed our algorithms data, show product recommendations, implement site wide search, register reviews, manage a users favorites and show smart and personalised ads.

To get started using our Javascript SDK. You start by initilaize it by using the code example below, we recommend adding it before your ending head tag. Just add your own token and secret that you can find in the Aikey Portal. Depending on if the user have visited your site before or not Aikey will create a new user and session. This will automatically be saved in cookies and Aikey will keep a track of these, so you don't have to worry about them, but if you it is possible to grab them in the callback function.

<script src="https://js.aikey.io/v1/aikey-connector.min.js"></script>
<script>
  Aikey.init({
    clientId: "4b5e173e683901b09021c35d2e18be81", 
    publicKey: "pk_8b5e173e683901b09021c35d2e18be81"
  }, function(data) {
  });
</script>

Response
{
  "userId": "U.5d45af5fcb75f9.31319840",
  "sessionId": "S.8d43af5fcb75f9.41319460"
}

Initialize an existing member

If you're site have a member system in place you can save your Aikey id to this user and initalize Aikey with that id and all of that users activites will be saved and used in Aikey. 

<script src="https://js.aikey.io/v1/aikey-connector.min.js"></script>
<script>
  Aikey.setUser("U.5d45af5fcb75f9.31319840");
  Aikey.init({
    clientId: "4b5e173e683901b09021c35d2e18be81", 
    publicKey: "pk_8b5e173e683901b09021c35d2e18be81"
  }, function(data) {
  });
</script>

Aikey Loaded

When adding a recommendation or getting favorites on the first load of a page you need to make sure that the user has been created and have a valid session. For that use we have a loaded method that will be run when everything is initialised.

Aikey.loaded(function () {
  //Put code in here
});

Great! Now we are ready to setup the events to start feeding Aikey data. Events