# 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 audiences section, enable "Use your own targeting platform".

<figure><img src="https://868424754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBe743z7FL4vw9wddyQ%2Fuploads%2FmoJvbZxzoZM4nc6WOe6l%2Fimage.png?alt=media&#x26;token=a4ce97ca-3974-42b8-9f37-5b227c02c88a" alt=""><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](https://docs.shipscout.app/tasks/headless-stores "mention").

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.
