Skip to content

Ad Performance Analytics

Analyze your advertising campaigns across Meta (Facebook/Instagram), Google Ads, Snapchat, and TikTok with true profit-based ROAS calculations.

GET /v1/analytics/ad-performance

Get comprehensive advertising performance metrics.

Parameters

ParameterTypeRequiredDescription
periodstringNotoday, yesterday, 7d, 30d, 90d (default: 30d)
platformstringNometa, google, snapchat, tiktok, all (default: all)
startDatestringNoCustom start date (YYYY-MM-DD)
endDatestringNoCustom end date (YYYY-MM-DD)

Example Request

bash
curl -H "Authorization: Bearer looha_your_api_key" \
  "https://api.looha.app/v1/analytics/ad-performance?period=30d&platform=meta"

Response

json
{
  "success": true,
  "data": {
    "platform": "meta",
    "totalSpend": 8000,
    "totalRevenue": 50000,
    "totalProfit": 15000,
    "roas": 6.25,
    "profitRoas": 1.88,
    "clicks": 15000,
    "impressions": 450000,
    "ctr": 3.33,
    "cpc": 0.53,
    "conversions": 250,
    "conversionRate": 1.67,
    "costPerConversion": 32.0
  }
}

Response Fields

FieldTypeDescription
totalSpendnumberTotal ad spend in SAR
totalRevenuenumberRevenue attributed to ads
totalProfitnumberNet profit after all costs
roasnumberRevenue ROAS (revenue / spend)
profitRoasnumberProfit ROAS (profit / spend) - unique to Looha
clicksnumberTotal ad clicks
impressionsnumberTotal ad impressions
ctrnumberClick-through rate (%)
cpcnumberCost per click
conversionsnumberNumber of conversions
conversionRatenumberConversion rate (%)
costPerConversionnumberCost per conversion

GET /v1/analytics/funnel

Analyze the complete conversion funnel from ad click to purchase.

Parameters

ParameterTypeRequiredDescription
periodstringNo7d, 30d, 90d (default: 30d)
platformstringNoPlatform filter

Example Request

bash
curl -H "Authorization: Bearer looha_your_api_key" \
  "https://api.looha.app/v1/analytics/funnel?period=30d"

Response

json
{
  "success": true,
  "data": {
    "funnel": [
      {
        "stage": "Ad Impressions",
        "count": 450000,
        "percentage": 100,
        "dropOff": 0
      },
      {
        "stage": "Ad Clicks",
        "count": 15000,
        "percentage": 3.33,
        "dropOff": 96.67
      },
      {
        "stage": "Store Visits",
        "count": 12000,
        "percentage": 2.67,
        "dropOff": 0.66
      },
      {
        "stage": "Add to Cart",
        "count": 3000,
        "percentage": 0.67,
        "dropOff": 2.0
      },
      {
        "stage": "Initiated Checkout",
        "count": 1500,
        "percentage": 0.33,
        "dropOff": 0.34
      },
      {
        "stage": "Completed Purchase",
        "count": 250,
        "percentage": 0.056,
        "dropOff": 0.27
      }
    ],
    "summary": {
      "totalImpressions": 450000,
      "totalOrders": 250,
      "overallConversionRate": 0.056
    }
  }
}

GET /v1/analytics/roas-by-platform

Compare ROAS across all advertising platforms.

Parameters

ParameterTypeRequiredDescription
periodstringNo7d, 30d, 90d (default: 30d)
sortBystringNoroas, profitRoas, spend, profit (default: profitRoas)

Example Request

bash
curl -H "Authorization: Bearer looha_your_api_key" \
  "https://api.looha.app/v1/analytics/roas-by-platform?period=30d&sortBy=profitRoas"

Response

json
{
  "success": true,
  "data": {
    "platforms": [
      {
        "platform": "meta",
        "spend": 8000,
        "revenue": 50000,
        "profit": 15000,
        "roas": 6.25,
        "profitRoas": 1.88,
        "orders": 250
      },
      {
        "platform": "google",
        "spend": 5000,
        "revenue": 35000,
        "profit": 10500,
        "roas": 7.0,
        "profitRoas": 2.1,
        "orders": 175
      },
      {
        "platform": "snapchat",
        "spend": 2000,
        "revenue": 10000,
        "profit": 3000,
        "roas": 5.0,
        "profitRoas": 1.5,
        "orders": 50
      },
      {
        "platform": "tiktok",
        "spend": 1000,
        "revenue": 6000,
        "profit": 1800,
        "roas": 6.0,
        "profitRoas": 1.8,
        "orders": 30
      }
    ],
    "totals": {
      "totalSpend": 16000,
      "totalRevenue": 101000,
      "totalProfit": 30300,
      "avgRoas": 6.31,
      "avgProfitRoas": 1.89
    }
  }
}

GET /v1/analytics/campaigns

Get performance breakdown by campaign.

Parameters

ParameterTypeRequiredDescription
periodstringNo7d, 30d, 90d (default: 30d)
platformstringNoFilter by platform
statusstringNoactive, paused, all (default: active)
limitnumberNoNumber of campaigns (default: 50)

Example Request

bash
curl -H "Authorization: Bearer looha_your_api_key" \
  "https://api.looha.app/v1/analytics/campaigns?period=30d&platform=meta&limit=10"

Response

json
{
  "success": true,
  "data": {
    "campaigns": [
      {
        "id": "camp_123",
        "name": "Winter Sale 2024",
        "platform": "meta",
        "status": "active",
        "spend": 3000,
        "revenue": 22000,
        "profit": 6600,
        "roas": 7.33,
        "profitRoas": 2.2,
        "clicks": 5500,
        "conversions": 110
      },
      {
        "id": "camp_456",
        "name": "Product Launch - Headphones",
        "platform": "meta",
        "status": "active",
        "spend": 2000,
        "revenue": 14000,
        "profit": 4200,
        "roas": 7.0,
        "profitRoas": 2.1,
        "clicks": 3800,
        "conversions": 70
      }
    ],
    "meta": {
      "total": 25,
      "showing": 10
    }
  }
}

GET /v1/analytics/attribution

Get detailed attribution data showing how orders are linked to ads.

Parameters

ParameterTypeRequiredDescription
periodstringNo7d, 30d, 90d (default: 30d)
attributionWindownumberNoDays to attribute (1-30, default: 7)

Example Request

bash
curl -H "Authorization: Bearer looha_your_api_key" \
  "https://api.looha.app/v1/analytics/attribution?period=30d&attributionWindow=7"

Response

json
{
  "success": true,
  "data": {
    "attributionModel": "last_click_7_day",
    "totalOrders": 450,
    "attributedOrders": 380,
    "attributionRate": 84.4,
    "breakdown": {
      "meta": {
        "orders": 200,
        "percentage": 52.6
      },
      "google": {
        "orders": 120,
        "percentage": 31.6
      },
      "snapchat": {
        "orders": 40,
        "percentage": 10.5
      },
      "tiktok": {
        "orders": 20,
        "percentage": 5.3
      }
    },
    "unattributedOrders": 70,
    "organicOrders": 70
  }
}

Understanding Profit ROAS

Profit ROAS is Looha's unique metric that shows true profitability:

Profit ROAS = (Revenue - All Costs) / Ad Spend

Example:

  • Revenue: 50,000 SAR
  • Product Cost: 30,000 SAR
  • Ad Spend: 8,000 SAR
  • Other Costs: 2,000 SAR

Traditional ROAS: 50,000 / 8,000 = 6.25xProfit ROAS: (50,000 - 30,000 - 2,000) / 8,000 = 2.25x

Profit ROAS shows you're actually making 2.25 SAR profit for every 1 SAR spent on ads, not 6.25 SAR.


Error Responses

400 Bad Request

json
{
  "success": false,
  "error": "Invalid platform. Must be: meta, google, snapchat, tiktok, or all"
}

404 Not Found

json
{
  "success": false,
  "error": "No advertising data found for this period"
}

Use Cases

Compare Platform Performance

python
import requests

API_KEY = 'looha_your_api_key'
response = requests.get(
    'https://api.looha.app/v1/analytics/roas-by-platform',
    params={'period': '30d'},
    headers={'Authorization': f'Bearer {API_KEY}'}
)

platforms = response.json()['data']['platforms']
best_platform = max(platforms, key=lambda p: p['profitRoas'])

print(f"Best performing platform: {best_platform['platform']}")
print(f"Profit ROAS: {best_platform['profitRoas']}x")

Track Funnel Drop-offs

javascript
const API_KEY = 'looha_your_api_key'

const response = await fetch(
  'https://api.looha.app/v1/analytics/funnel?period=30d',
  {
    headers: { 'Authorization': `Bearer ${API_KEY}` }
  }
)

const funnel = await response.json()
const stages = funnel.data.funnel

stages.forEach((stage, index) => {
  if (index > 0) {
    console.log(`${stage.stage}: ${stage.dropOff}% drop-off`)
  }
})

Next: AI Recommendations →

Profit analytics platform for Saudi e-commerce merchants