Skip to main content
The Shopify integration connects your Shopify store to DATALYR for complete revenue attribution, profit tracking, and customer journey analysis.

What Gets Synced

Orders:
  • Order ID, order number, created date
  • Total price, currency, line items
  • Customer email, customer ID
  • Discount codes, tags
  • Financial status, fulfillment status
  • Refunds and cancellations
Products:
  • Product title, SKU, vendor, type
  • Cost per item (COGS)
  • Price, compare at price
  • Inventory quantity
Customers:
  • Email, name, phone
  • Customer ID, created date
  • Total orders, lifetime value
Events Tracked:
  • order_paid - Order payment received
  • order_fulfilled - Order shipped
  • order_cancelled - Order cancelled
  • checkout_completed - Checkout completed
  • checkout_abandoned - Cart abandoned
  • customer_created - New customer registered

Setup

1. Connect Your Shopify Store

Via Shopify App Store (Recommended):
  1. Install DATALYR app from Shopify App Store
  2. Click “Add app” to authorize DATALYR
  3. Grant read permissions for orders, products, customers
  4. DATALYR automatically configures tracking and webhooks
Via DATALYR Dashboard:
  1. Navigate to Settings → Integrations
  2. Click “Connect” next to Shopify
  3. Enter your Shopify store URL (e.g., yourstore.myshopify.com)
  4. Authorize DATALYR in Shopify admin
  5. Grant read permissions

2. Install Tracking Script

Add DATALYR tracking to your Shopify store: Option A: Via App (Automatic) If you installed via Shopify App Store, tracking is automatically added via Web Pixels API. Option B: Manual Installation If you connected via DATALYR dashboard:
  1. Go to Shopify Admin → Online Store → Themes
  2. Click “Actions” → “Edit code”
  3. Open theme.liquid
  4. Add DATALYR script before </head>:
<!-- DATALYR Tracking -->
<script defer src="https://track.datalyr.com/dl.js" data-workspace-id="ws_YOUR_WORKSPACE_ID"></script>
  1. Save changes

3. Configure Webhooks

Webhooks enable real-time order sync. Via App (Automatic): Webhooks are automatically configured when you install the DATALYR Shopify app. Manual Configuration:
  1. Go to Shopify Admin → Settings → Notifications
  2. Scroll to “Webhooks” section
  3. Create these webhooks pointing to your DATALYR webhook URL:
Order Webhooks:
  • Event: Order payment → https://app.datalyr.com/api/shopify/webhook
  • Event: Order fulfillment → https://app.datalyr.com/api/shopify/webhook
  • Event: Order cancelled → https://app.datalyr.com/api/shopify/webhook
Checkout Webhooks:
  • Event: Checkout creation → https://app.datalyr.com/api/shopify/webhook
Format: JSON

4. Verify Integration

Test Order:
  1. Create a test order in your Shopify store
  2. Go to DATALYR Dashboard → Event Stream
  3. Verify order_paid event appears
  4. Check that customer email matches
Check Attribution:
  1. Click on the order event in Event Stream
  2. Verify attribution data (source, medium, campaign)
  3. Confirm customer journey is linked

Order Sync

How It Works

Real-Time Sync (Webhooks):
Customer completes checkout in Shopify
→ Shopify sends webhook to DATALYR
→ DATALYR receives order data
→ Matches customer email to visitor profile
→ Links order to original ad click attribution
→ Creates order_paid event in Event Stream
→ Sends conversion to Meta/Google/TikTok
Scheduled Sync (API):
Every 15 minutes:
→ DATALYR fetches recent orders via Shopify API
→ Syncs any missing orders (webhook backup)
→ Updates order status changes
→ Syncs refunds and cancellations

Order Attribution

DATALYR attributes orders to marketing sources using email matching: Step 1: User Clicks Ad
User clicks Facebook ad
DATALYR captures: fbclid=IwAR123, utm_source=facebook
Stores in visitor profile: anon_abc123
Step 2: User Browses
User views products, adds to cart
All events tracked with Facebook attribution
Step 3: User Checks Out
User enters email: [email protected]
Completes purchase in Shopify
Step 4: Order Synced
DATALYR syncs order via webhook
Searches for visitor with email: [email protected]
Finds visitor: anon_abc123
Links order to fbclid: IwAR123 from Day 1
Step 5: Conversion Sent
DATALYR sends conversion to Meta CAPI
Includes: fbclid=IwAR123, value=$99.99
Meta attributes conversion to original ad
Result: Order correctly attributed to Facebook ad, even if purchase happened days later.

Order Events

order_paid: Fired when order payment is received.
{
  "event_name": "order_paid",
  "value": 99.99,
  "currency": "USD",
  "order": {
    "id": "5123456789",
    "order_number": "1001",
    "total_price": "99.99",
    "currency": "USD",
    "line_items": [...],
    "financial_status": "paid"
  },
  "customer_email": "[email protected]",
  "attribution": {
    "utm_source": "facebook",
    "utm_medium": "cpc",
    "fbclid": "IwAR123"
  }
}
order_fulfilled: Fired when order is shipped. order_cancelled: Fired when order is cancelled or refunded. checkout_completed: Fired when checkout process completes (derived from order_paid). checkout_abandoned: Fired when user abandons cart without purchasing.

Profit Tracking

DATALYR calculates profit by syncing product costs from Shopify.

Setup Product Costs

In Shopify Admin:
  1. Go to Products → Select a product
  2. Scroll to “Variants” section
  3. Enter “Cost per item” for each variant
  4. Save product
Bulk Import: Use Shopify’s CSV import to add costs:
  1. Export products as CSV
  2. Add “Variant Cost” column
  3. Fill in costs for each variant
  4. Import CSV back to Shopify

How Profit is Calculated

// Per Order
Profit = Order Total - Total Product Costs - Shipping Cost - Taxes

// Example
Order Total: $99.99
Product Cost 1: $20.00 (Widget × 1)
Product Cost 2: $15.00 (Gadget × 1)
Shipping: $5.00
Total Cost: $40.00

Profit = $99.99 - $40.00 = $59.99
Profit Margin = ($59.99 / $99.99) × 100 = 60%

Profit Metrics in Dashboard

DATALYR Dashboard shows:
  • Total revenue
  • Total cost (COGS)
  • Total profit
  • Profit margin (%)
  • ROAS (return on ad spend)
  • Profit per order
  • Profit by source/medium/campaign
Filter by:
  • Date range
  • Source (Facebook, Google, TikTok, etc.)
  • Campaign
  • Product
  • Customer

Customer Journey

DATALYR links Shopify customers to their complete journey from first touch to purchase.

Journey Example

Day 1: First Visit (Anonymous)
User clicks Facebook ad
DATALYR tracks:
  - anonymous_id: anon_abc123
  - fbclid: IwAR123
  - utm_source: facebook
  - Event: page_view
Day 1: Product Viewed
User views product page
DATALYR tracks:
  - anonymous_id: anon_abc123 (same)
  - Event: product_viewed
  - Attribution preserved: facebook / cpc
Day 3: Returns to Site
User returns via Google search
DATALYR tracks:
  - anonymous_id: anon_abc123 (same cookie)
  - New session: google / organic
  - Journey continues
Day 3: Checks Out
User enters email: [email protected]
Completes Shopify checkout
Order Total: $99.99
Day 3: Order Synced
DATALYR syncs order:
  - Matches email to anon_abc123
  - Links order to original fbclid
  - Creates order_paid event
  - Attributes to Facebook ad from Day 1
Result in Dashboard: Complete journey visible:
  • First touch: Facebook ad (Day 1)
  • Middle touch: Google organic (Day 3)
  • Last touch: Direct checkout (Day 3)
  • Conversion attributed to Facebook (first-touch) or Direct (last-touch)

Customer Lifetime Value

DATALYR tracks customer LTV:
  • Total orders per customer
  • Total revenue per customer
  • Average order value
  • Repeat purchase rate
  • Time between orders
Segment customers by:
  • Acquisition source
  • First order date
  • Total spent
  • Order count

Advanced Features

Abandoned Cart Recovery

Track abandoned checkouts for retargeting: What Gets Tracked:
  • Checkout ID, token
  • Items in cart
  • Total value
  • Customer email (if provided)
  • Abandonment timestamp
Use Cases:
  • Send abandoned cart emails
  • Create retargeting audiences
  • Track recovery rate
  • Measure cart abandonment by source

Multi-Currency Support

DATALYR handles multiple currencies:
  • Orders synced in original currency
  • Dashboard shows currency breakdown
  • Conversions sent to ad platforms in original currency
  • Optional currency conversion for reporting

Discount Code Tracking

Track discount code performance:
  • Which codes are used
  • Revenue per discount code
  • Discount attribution to campaigns
  • ROI of discount campaigns

Tags and Segments

Use Shopify tags for segmentation:
  • VIP customers
  • Wholesale orders
  • Subscription orders
  • Gift purchases
DATALYR syncs tags and allows filtering by tag.

Troubleshooting

Orders Not Appearing in DATALYR

Check:
  1. Integration is connected and active (Settings → Integrations)
  2. Webhooks are configured correctly in Shopify Admin
  3. Webhook URL is: https://app.datalyr.com/api/shopify/webhook
  4. Order is within sync window (last 30 days)
Test:
  • Create a test order in Shopify
  • Check Event Stream within 1 minute
  • If not appearing, check webhook delivery in Shopify Admin

Orders Not Attributed

Verify:
  1. Customer email in order matches visitor email
  2. Visitor was tracked before purchase (check Event Stream)
  3. Attribution window not exceeded (default 30 days)
  4. Tracking script is installed on site
Check Visitor Profile:
  • Go to Event Stream
  • Search for customer email
  • Verify events exist before order
  • Confirm attribution data present (utm_source, fbclid, etc.)

Profit Showing as Zero

Fix:
  1. Add product costs in Shopify Admin (Products → Cost per item)
  2. Wait for next sync (up to 15 minutes)
  3. Refresh DATALYR dashboard
  4. Verify costs appear in order details

Duplicate Orders

Causes:
  • Webhook and API sync both creating orders
  • Shopify sending duplicate webhooks
Prevention:
  • DATALYR automatically deduplicates by order ID
  • If seeing duplicates, contact support with order ID

Data Privacy

Customer Data:
  • Customer emails are hashed before sending to ad platforms
  • SHA-256 hashing compliant with GDPR
  • No plaintext PII sent to Meta/Google/TikTok
Data Retention:
  • Orders retained indefinitely for reporting
  • Customer data retained for attribution
  • Users can request data deletion
GDPR Compliance:
  • Opt-out respected across all platforms
  • No data synced for opted-out users
  • Data deletion on request

Next Steps

Need Help?

Questions about Shopify integration? Check our troubleshooting guide or contact support.