Emarsys Predict SDK is a powerful tool that enables personalized product recommendations, helping businesses enhance their customer shopping experience and drive revenue growth. With the Predict SDK, you can implement machine learning algorithms to offer tailored product recommendations to your customers in real-time. This documentation will guide you through the installation process and provide detailed information on how to use the Emarsys Predict SDK effectively.
#### Table of Contents * [Installation](#installation) * [Getting Started](#getting-started) * [Methods](#methods) * [setCustomerId](#setcustomerid) * [getRecommendations](#getrecommendations) * [trackTransaction](#tracktransaction) * [Examples](#examples) * [Basic Usage](#basic-usage) * [Advanced Usage](#advanced-usage) * [FAQ](#faq) * [Support](#support) ### InstallationTo install the Emarsys Predict SDK, you can follow these simple steps:
1. Navigate to the official Emarsys Predict SDK GitHub repository at [https://github.com/emarsys/predict-sdk](https://github.com/emarsys/predict-sdk). 2. Clone or download the repository to your local machine. 3. Drag the SDK files into your project. 4. Import the necessary classes and files into your development environment. 5. You’re ready to start using the Emarsys Predict SDK! ### Getting StartedBefore you can effectively utilize the Emarsys Predict SDK, you need to set up the necessary configuration and initialize the SDK. Here’s how you can get started:
1. Import the Emarsys Predict SDK into your project. 2. Set up the configuration parameters specifying your environment, client credentials, and other related information. 3. Initialize the Emarsys Predict SDK using the configuration parameters. 4. Ensure that the SDK initializes successfully before further implementation. ### MethodsThe Emarsys Predict SDK provides various methods to interact with the recommendation engine. Here are the key methods:
#### setCustomerIdThe `setCustomerId` method is used to set the unique identifier for the current customer. This identifier is crucial for generating personalized recommendations based on the customer’s previous interactions.
“`php EmarsysPredict::setCustomerId($customerId); “` #### getRecommendationsThe `getRecommendations` method is the primary function for retrieving personalized product recommendations. It takes the following parameters:
* `categoryId` – [optional] Specify a particular category from which to retrieve recommendations. * `limit` – [optional] Limit the number of recommendations returned. * `filter` – [optional] Apply specific filters to the recommendations. “`php $recommendations = EmarsysPredict::getRecommendations($categoryId, $limit, $filter); “` #### trackTransactionThe `trackTransaction` method is used to track the customer’s transaction and update the recommendation engine accordingly. It provides crucial data for enhancing future recommendations based on the customer’s purchase history.
“`php EmarsysPredict::trackTransaction($transactionId, $items); “` ### ExamplesHere are a few examples demonstrating how to use the Emarsys Predict SDK in your application:
#### Basic Usage “`php // Set Customer ID EmarsysPredict::setCustomerId($customerId); // Retrieve recommendations $recommendations = EmarsysPredict::getRecommendations(); // Display recommendations to the user foreach($recommendations as $recommendation) { echo $recommendation[‘name’] . ‘‘; } “` #### Advanced Usage “`php // Set Customer ID EmarsysPredict::setCustomerId($customerId); // Retrieve recommendations for a specific category $recommendations = EmarsysPredict::getRecommendations(‘electronics’, 5); // Apply filters to recommendations $filter = array(‘price’ => array(‘gte’ => 50)); $recommendations = EmarsysPredict::getRecommendations(‘electronics’, 5, $filter); // Track transaction and update recommendations $transactionId = uniqid(); $items = array( array( ‘itemId’ => ‘123’, ‘price’ => 99.99, ‘quantity’ => 2 ), array( ‘itemId’ => ‘456’, ‘price’ => 49.99, ‘quantity’ => 1 ) ); EmarsysPredict::trackTransaction($transactionId, $items); “` ### FAQ #### Can I use the Emarsys Predict SDK with my existing eCommerce platform?
Yes, the Emarsys Predict SDK is compatible with most major eCommerce platforms. It provides easy integration and supports seamless personalized recommendations regardless of the platform you are using. Refer to our comprehensive integration guides and documentation for platform-specific instructions.
#### Are there any limitations on the number of recommendations I can retrieve?The number of recommendations you can retrieve using the Emarsys Predict SDK is highly customizable. You can specify the limit yourself or leave it empty to retrieve recommendations without a predefined cap. However, it is recommended to set a sensible limit to ensure optimal performance and avoid overwhelming your users with a large number of recommendations.
### SupportIf you need any assistance or have any questions regarding the Emarsys Predict SDK, feel free to reach out to our support team. We are dedicated to ensuring your success with our product and providing timely solutions to any issues you may encounter during implementation.