# Bring your own targeting platform

{% hint style="warning" %}
Requires engineering work
{% endhint %}

### Why would I want this?

Many of our merchants use a generalized A/B test platform for non-shipping rate experiments. This feature allows you to utilize the power of ShipScout's shipping rate configurability with your own existing targeting tool.

### Step 1 - Set up your test

Create a ShipScout test as you normally would. BYOTP is available to all types of tests: threshold, flat rate and custom.

### Step 2 - Enable "Use your own targeting platform"

In the **Audience** section, expand the **External assignment** row and enable "Use your own targeting platform".

<figure><img src="/files/TYykrxqe8ruClsLtZswg" alt="The Audience section of the experiment editor with the &#x27;External assignment&#x27; disclosure row expanded, showing the unchecked &#x27;Use your own targeting platform (disables ShipScout)&#x27; checkbox."><figcaption></figcaption></figure>

### Step 3 - Integrate your platform

Use the ShipScout javascript SDK to assign a variant to your visitors. For theme based shops, no pre-setup is necessary. For headless shops, you'll need to install the javascript SDK by following this guide: [Headless stores](/tasks/headless-stores.md).

Here's an example of assigning variant A to all visitors:

<pre class="language-javascript"><code class="lang-javascript">// Init ShipScout - this must run before you assign the variant
!function(s) { s.shipscout = s.shipscout || (e, a) => { s.shipscout._queue?.push({ type: e, ...a }); }; s.shipscout._queue = s.shipscout._queue || [];}(window)

<strong>// Assign the variant
</strong>window.shipscout("assign", {
  variantKey: "A" // all visitors will be assigned to variant A
});
</code></pre>

Here's a more plausible example that shows how you might get an assignment from a targeting platform and map it to a ShipScout variant

```javascript
// Init ShipScout
!function(s) { s.shipscout = s.shipscout || (e, a) => { s.shipscout._queue?.push({ type: e, ...a }); }; s.shipscout._queue = s.shipscout._queue || [];}(window)

// Get assignment from you experimentation platform
const assignment = ExampleTargtingPlatform.getAssignment();

// Map assignment to ShipScout variants. ShipScout variants are always
//  capital letters starting from A.
let shipScoutAssignment;
if (assignment === "12390424") {
  shipScoutAssignment = "A";
} else if (assignment === "4214900") {
  shipScoutAssignment = "B";
}

// Assign the variant
window.shipscout("assign", {
  variantKey: shipScoutAssignment
});
```

A few things to keep in mind:

* Once a visitor is assigned to a variant, their assignment will persist for the duration of the test.
* Once a test ends, the assignment code will noop so you can clean it up at your leisure. But be sure to clean it up before you start your next experiment.

### Step 4 - Test your changes

In order to test the assignments, you will need to launch your test. Assignments will not work in draft mode.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.shipscout.app/tasks/bring-your-own-targeting-platform.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
