Crownpeak
  • Product Discovery Developer Guide
  • 🛒Item catalog management
    • What is the Items API?
    • How to work with Items
      • Item Schema
        • Attributes
        • Nested Item Schemas
        • Using the Item Schema API
        • DefaultLocale API
        • Onboarding on/migrating to Fredhopper
        • List of Reserved Attributes
      • Category Tree
        • Using the Category Tree API
        • Onboarding on XO
      • Item Catalog
        • Using the Catalog API
      • Items
        • Using the streaming Items API
        • Using the batch Items API
    • Step by Step guide
      • Step by step guide for Fredhopper customers
    • Feedback
      • Using the Feedback API
    • Authorization to APIs
    • Troubleshooting API errors
  • 🎯XO Recommendations
    • Introduction
    • Using the Recommendations API
    • Setting up the Chrome extension
    • Micro-segmentation
    • XO Legacy APIs
  • 🔎XO Search
    • Introduction
    • Getting started
    • API Reference
      • Search API
      • Autocomplete API (Beta)
      • Product Suggest API
    • API Parameters
      • Search
      • Pagination
      • Faceting
      • Sorting
      • Grouping
      • Filtering
      • Disable features
      • Response mask
      • Context
    • Configuration limitation
  • 🧪A/B testing
    • Fredhopper A/B testing
      • Integration steps for a non-caching solution
      • Integration steps for a caching solution
        • Java SDK Integration
          • Setup
          • Retrieve running A/B tests - Java SDK
          • Filter and request variant - Java SDK
          • Extending the SDK
        • Manual A/B tests integration
          • Retrieve running A/B tests
          • Filter out irrelevant A/B tests
          • Assign variants to user
          • Request variant for page
        • Limitations and Best Practices
  • 📚Resources
    • Glossary
    • Best Practices
      • Tracker Best Practices
      • Items API Best Practices
      • Fredhopper Data Configuration Best Practices
      • Fredhopper Query Response Best Practices
      • Fredhopper Merchandising Studio Best Practices
    • Privacy Notice
  • Archived Pages
    • FHR Tracking plan
    • XO Tracking plan
    • The Tracking API and JS Library
      • What to Track
        • Generic Actions
          • View
          • Click
          • Add to Cart
          • Remove from Cart
          • Purchase
        • Custom Actions
      • Initializing the JavaScript Library
      • REST API Technical Documentation
Powered by GitBook
On this page
  • Installation
  • Maven
  • Gradle
  • Initialization
  • Standard
  • Custom
  • Use
  1. A/B testing
  2. Fredhopper A/B testing
  3. Integration steps for a caching solution
  4. Java SDK Integration

Setup

Installation

Our SDK is free to use and it's available as a package on Maven Central repository. You can add it to your project easily through either Maven or Gradle.

Maven

<dependencies>
...
        <dependency>
            <groupId>com.attraqt</groupId>
            <artifactId>sdk-fhr-ab-testing</artifactId>
            <version>1.0.0</version>
        </dependency>
...
</dependencies>

Gradle

dependencies {
    implementation 'sdk-fhr-ab-testing:1.0.0'
}

Important! Make sure you include the latest version for the most up to date features and functionality.

Initialization

Standard

In order to be able to initialize your SDK you will need the following:

  • url - the base URL for getting the running A/B tests provided by the technical consultant (without the path /config/running/ab-tests).

  • username and password - the Basic Authentication credentials you normally use for all your FHR queries.

To initialize the SDK in your Java code you can look at the following snippet.

 import com.attraqt.sdk.fhr.abtesting.AbTesting

...

AbTesting abTesting = AbTesting.builder()
                               .abTestsServerUrl("url")
                               .username("username")
                               .password("password")       
                               .build();

abTesting.start();

This is the most basic initialization you can do. The call to start() at the end, starts the retrieval of running A/B tests on a periodic basis of 5 minutes by default, storing the response in the mean time.

This should be enough for most use cases. However, the SDK offers a bit more customization.

Custom

Apart from the mandatory url, username and password, you can also supply the following details:

  • cacheExpireTimeMinutes - Integer - the SDK caches the running A/B tests, and you can control the time between refreshes. The minimum and also default expire time of the cache is 5 minutes. If you provide a number lower than 5, the time will be set to 5.

  • abTestsCache - AbTestsCache object - Provide a custom implementation of the AbTestCache object to override the provided in-memory caching behavior.

    Only set if custom caching logic is required. Default implementation should be used as standard.

  • runningAbTestsFetcher - RunningAbTests object - Provide a custom implementation of the RunningAbTests object to override the provided ab-tests fetching behaviour.

    Only set if custom ab-tests fetching logic is required. Default implementation should be used as standard.

For the abTestsCache and the runningAbTestsFetcher, you can check out the extension section.

Use

PreviousJava SDK IntegrationNextRetrieve running A/B tests - Java SDK

Last updated 3 years ago

Once initialized you can check out the corresponding pages on each of the key functionalities available in the SDK. **These pages essentially cover a built-in implementation of what's covered in the . You can start with the first step - Retrieve running A/B tests.**

🧪
Extending the SDK
Overview
Retrieve running A/B tests - Java SDK