> For the complete documentation index, see [llms.txt](https://docs.hackle.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackle.io/en/development-guide/sdk/sdk-example.md).

# Tutorial / Example: Simple A/B Test

This document introduces an example using the JavaScript SDK from Hackle's supported SDKs. The purpose of the example is to:

1. Understand what code work is needed.
2. Experience the features of the SDK.

## Example: Simple A/B Test

The example performs the following:

1. Accepts an arbitrary User Identifier as input.
2. Clicks the **Variation Distribution** button.
3. Performs variation distribution and tracks the `hackle_test_event_key` event.

{% hint style="info" %}
View example code and practice link

[Hackle JavaScript SDK Integration and Feature Example](https://codepen.io/hackle-example/pen/wvdedja)

Tip. Reading the [JavaScript](https://docs.hackle.io/en/development-guide/javascript.md) documentation alongside the comments in the code will help you understand it quickly.
{% endhint %}

## Notes

1. **The example runs based on an A/B test created by Hackle for demonstration purposes. This example A/B test has the following characteristics:**
   * It is configured to let you experience multiple types of distribution reasons.
   * Entering `apple` as the User Identifier returns variation A, and `banana` returns variation B.
   * For other input values, the variation is determined according to the Variation Distribution Principle.
2. **To run this example with an A/B test you created in the Hackle Dashboard, you need to modify the SDK Key and Experiment Key in the JS tab.**

![](https://143363954-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyAVlNQhS253reum0Ce94%2Fuploads%2Fgit-blob-20d7f5a9598a394c9ee915449532f93802f23815%2Fdc21d99-ab-example-custom_dd940b603f238685.png?alt=media)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.hackle.io/en/development-guide/sdk/sdk-example.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
