# Tagging Orders in Shopify

### Overview

To ensure Eraya can correctly attribute orders to their respective test variations (Control or Variant), you’ll need to set up an automated workflow in **Shopify Flow**.\
This workflow uses **custom attributes** that Eraya adds during checkout to tag orders in Shopify with the correct **test ID** and **variation (A/B)**.

***

### ⚙️ Prerequisites

Before you begin:

1. Make sure you have installed the [**Shopify Flow app**](https://apps.shopify.com/flow).
2. Identify the **test type** and copy its **test ID** from your Eraya dashboard.

| Test Type         | Test ID Attribute         | Variation Attribute         |
| ----------------- | ------------------------- | --------------------------- |
| **Price Test**    | `_eraya_test_id`          | `_eraya_variation`          |
| **Theme Test**    | `_eraya_theme_test_id`    | `_eraya_theme_variation`    |
| **Shipping Test** | `_eraya_shipping_test_id` | `_eraya_shipping_variation` |

***

### Steps to Create the Workflow

#### 1. Create a New Workflow

* Open the **Shopify Flow app** in your Shopify admin.
* Click **Create workflow** (top-right).
* Click **Select a trigger**.
* For the trigger, choose **Order created**.

***

#### 2. Add a Condition

* Click the **blue “+”** icon on the **Order created** card and select **Condition**.
* Click **Add criteria** → **Order** → **lineItems** → **customAttributes** → **value**.
* Change the **“Equals”** dropdown to **“Includes”**.
* Paste your **test ID** (copied from the Eraya dashboard) into the **Value** field.

<figure><img src="/files/ZjpiCFWxvw7cq8FjHLSG" alt=""><figcaption></figcaption></figure>

\
Example:

```
68c84559308bf515cf681476
```

***

#### 3. Add an Action (Variation B)

* Click the **blue “+”** next to **Then** in the “Check if…” card and select **Action**.
* Choose **Add order tags**.
* Add the following tags:

  ```
  B, 68c84559308bf515cf681476
  ```

  *(Replace the ID with your actual test ID.)*

***

#### 4. Add a Second Condition (Variation A)

* Below the **False** branch, click **Add condition** again.
* Use the same structure:
  * **Order → lineItems → customAttributes → value**
  * Change **Equals** to **Includes**
  * Enter the same test ID.
* Then add another criterion:
  * **Order → lineItems → customAttributes → value**
  * Change **Equals** to **Includes**
  * Enter `a` for the control group.

***

#### 5. Add an Action (Variation A)

* Under the **True** branch, select **Add order tags**.
* Add tags for the control group:

  ```
  A, 68c84559308bf515cf681476
  ```

***

#### 6. Activate the Workflow

Once your flow looks similar to the diagram below (with both **A** and **B** branches configured):

```
Order created
   ↓
Condition (_eraya_test_id includes TestID, _eraya_variation includes b)
   ├── True → Add order tags: "B, <TestID>"
   └── False → Condition (_eraya_test_id includes TestID, _eraya_variation includes a)
                 ├── True → Add order tags: "A, <TestID>"
```

Click **Turn on workflow** (top-right corner) to activate it.

***

### Example Attribute Values

Here’s how Eraya sends attributes to Shopify:

```js
// Price Test
{
  _eraya_test_id: "68c84559308bf515cf681476",
  _eraya_variation: "a" // or "b"
}

// Theme Test
{
  _eraya_theme_test_id: "78d21459abc874f951c",
  _eraya_theme_variation: "b"
}

// Shipping Test
{
  _eraya_shipping_test_id: "98f84559308bf515cf681aa",
  _eraya_shipping_variation: "a"
}
```

***

### Notes

* You can duplicate this same workflow for each **test type** (Price, Theme, Shipping) by simply updating the attribute keys.
* Always tag both the **variation (A/B)** and the **test ID** — this allows Eraya’s analytics to group and attribute orders correctly.
* Once enabled, every order will automatically include tags like:

  ```
  A, 68c84559308bf515cf681476
  ```

  or

  ```
  B, 68c84559308bf515cf681476
  ```


---

# 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://eraya.gitbook.io/eraya-docs/eraya-analytics-specification/tagging-orders-in-shopify.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.
