Using Contact Metrics

Prerequisites

Before you can track Contact metrics, you must create a Contact profile. Our Create Contacts guide provides detailed instructions on this process.

Tracking Contact metrics

To track Contact metrics effectively, you have two primary options:

  1. API Direct Usage:
    When using the API directly, you can attach the contact ID through the request headers.
  2. SDK Implementation:
    We strongly recommend using our SDKs, as they provide a more streamlined approach to tracking contact metrics.

curl 'https://api.orq.ai/v2/deployments/invoke' \
-H 'Authorization: Bearer {apiKey}' \
-H 'X-ORQ-CONTACT-ID: <external_id>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
--data-raw '{
   "key": "<deployment_key>",
   "context": {
      "environments": []
   }
}' \
--compressed
import { createClient } from '@orq-ai/node';

const client = createClient({
  apiKey: 'orq-api-key',
  environment: 'production',
});

client.setContact({
  id: '<user-id>',
  display_name: 'John Doe',
  email: '[email protected]',
  avatar_url: 'https://acme.com/john-doe.jpg',
  metadata: { role: 'admin' },
});
import os
from orq_ai_sdk import OrqAI

client = OrqAI(
    api_key=os.environ.get("ORQ_API_KEY", "__API_KEY__"), environment="production"
)

client.set_contact(
    id="<user-id>",
    display_name="John Doe",
    email="[email protected]",
    avatar_url="https://acme.com/john-doe.jpg",
    metadata={"role": "admin"},
)

📘

Developers, please see the API Reference for further explanation.