> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tracklysms.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Shopify

# Shopify Integration Guide

Shopify doesn't have built-in external form webhooks, but you can embed the opt-in widget via script tag or iframe.

## Method 1: Script Tag via Theme Editor (Recommended)

### Step 1: Add the script

1. In your Shopify admin, go to **Online Store → Themes**
2. Click **Actions → Edit Code** (or the `...` menu → Edit Code)
3. Open `theme.liquid` in the **Layout** folder
4. Paste your script tag just before `</body>`:
   ```html theme={null}
   <script src="https://api.tracklysms.com/optin/script.js?token=YOUR_PUBLIC_TOKEN" async></script>
   ```
5. Click **Save**

This adds the opt-in popup/widget to every page on your store.

### Step 2: Configure trigger settings

In your Trackly opt-in configuration, set the trigger type (delay, on form submit, or exit intent) to control when the popup appears. The script handles everything automatically.

## Method 2: Iframe on a Custom Page

1. In Shopify admin, go to **Online Store → Pages**
2. Click **Add page**
3. In the page editor, click the `<>` (HTML) button to switch to code view
4. Paste:
   ```html theme={null}
   <iframe src="https://api.tracklysms.com/optin/page/YOUR_PUBLIC_TOKEN" width="100%" height="520" frameborder="0" style="border:none;max-width:480px;margin:0 auto;display:block;"></iframe>
   ```
5. Save and publish the page

## Method 3: Shopify Flow + Webhook (for existing Shopify forms)

If you're collecting phone numbers through Shopify's native customer registration or checkout:

1. Install **Shopify Flow** (free on Shopify Plus, or via the app store)
2. Create a new workflow:
   * **Trigger**: Customer created (or Order placed)
   * **Action**: Send HTTP request
   * **URL**: `https://api.tracklysms.com/api/v2/optins/webhook`
   * **Method**: POST
   * **Headers**: `X-Api-Key: trk_your_api_key_here`, `Content-Type: application/json`
   * **Body**:
     ```json theme={null}
     {
       "phone_number": "{{ customer.phone }}",
       "list_id": YOUR_LIST_ID,
       "consent_text": "By providing your phone number, you agree to receive SMS marketing. Reply STOP to unsubscribe.",
       "first_name": "{{ customer.firstName }}",
       "last_name": "{{ customer.lastName }}",
       "email": "{{ customer.email }}"
     }
     ```
3. Enable the workflow

## Universal Methods

These bypass Shopify entirely:

* **Keyword opt-in**: Add "Text JOIN to (555) 555-5555" to product descriptions or your store footer
* **QR code**: Print on packaging, receipts, or marketing materials
* **Subscribe link**: Add to your store navigation or post-purchase page
