# Tagging Orders by Test Group in Shopify

## Background

When an order is created in Shopify and the user was included in an Intelligems test(s), there are a few ways that Intelligems will show up on the order within your Shopify admin portal. One thing that will be added by default is a **cart attribute** named `igTestGroups`, which contains the test group ID corresponding to the specific variant the visitor was assigned to for each test they participated in.

You can always get information about orders and their corresponding test groups by using our order export feature in the Intelligems app, but by following the below steps to setup a Shopify Flow, you will automatically get a tag on your Shopify orders to give you this information.

{% hint style="warning" %}
You'll have to set up a Shopify Flow for each test as they are based on the unique Test Group IDs that are assigned to each test group.
{% endhint %}

## Step 1: Get Test Group IDs

For every test set up in the Intelligems app, each test group receives a unique ID. You can get this information by clicking the "Show Info" option in the more options menu:

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

## Step 2: Set up a workflow in Shopify Flow

If you have not already, download the Shopify Flow app [here](https://apps.shopify.com/flow?shpxid=c54acb63-0029-409E-E10D-2F3BA56235EC). Once you are in the app:

1. Click "Create workflow" in the top right, followed by "Select a trigger".
2. For the trigger, select "Order created".
3. Click the blue plus sign in the "Order created" card and select "Condition".
4. Click "Add criteria" > "Order" > "customAttributes" > "value".
5. Change the "Equal to" dropdown to "Includes" and paste the test group ID (from Step 2) in the "Value" box.
6. Click the blue plus sign next to "Then" in the "Check if..." card and select "Action".
7. Click "Add order tags" and type the tag you would like to add to the orders for this test group(s). This tag will be added to all orders completed in this test group(s) in Shopify. When it is done, your Shopify Flow should look similar to the below.
8. Click "Turn on workflow" in the top right.

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

***

## ID as a Line Item Property

If you prefer to have the Test Group ID also added as a **custom line item property** under each item in the order and use that value instead, you may [reach out to Intelligems support](https://portal.usepylon.com/intelligems/forms/intelligems-support-request) for help enabling the setting "Add Test Group ID", which allows Intelligems to add the test group ID as a line item property. Some brands use line item properties for other workflows, so it is important to check that this will not break anything that you are currently doing.


---

# 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.intelligems.io/analytics/experiment-analytics/tagging-orders-by-test-group-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.
