For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/fr/api/latest/product-analytics/send-server-side-events.md. A documentation index is available at /llms.txt.
Language
Datadog site

Envoyer des événements côté serveur

POSThttps://browser-intake-datadoghq.com/api/v2/prodlyticshttps://browser-intake-us3-datadoghq.com/api/v2/prodlyticshttps://browser-intake-us5-datadoghq.com/api/v2/prodlyticshttps://browser-intake-datadoghq.eu/api/v2/prodlyticshttps://browser-intake-ap1-datadoghq.com/api/v2/prodlyticshttps://browser-intake-ap2-datadoghq.com/api/v2/prodlyticshttps://browser-intake-uk1-datadoghq.com/api/v2/prodlyticsNot supported in the US1-FED regionNot supported in the US2-FED region

Présentation

Envoyer des événements côté serveur à Product Analytics. Les événements côté serveur sont conservés pendant 15 mois.

Les événements côté serveur dans Product Analytics sont utiles pour suivre les événements qui se produisent sur le serveur, par opposition aux événements côté client, qui sont capturés par les SDK Real User Monitoring (RUM). Cela permet d'obtenir une vue plus complète du parcours utilisateur en incluant les actions qui se produisent sur le serveur. Des exemples typiques pourraient être checkout.completed ou payment.processed.

Les événements côté serveur ingérés sont intégrés dans Product Analytics pour permettre aux utilisateurs de sélectionner et de filtrer ces événements dans le sélecteur d'événements, de la même manière que les vues ou les actions sont gérées.

Prérequis :

  • Au moins l'un des champs usr, account ou session doit être fourni avec un ID valide.
  • L'application.id doit référencer une application avec Product Analytics activé.

Attributs personnalisés : Tous les champs supplémentaires de la charge utile sont aplatis et consultables en tant que facettes. Par exemple, une charge utile contenant {"customer": {"tier": "premium"}} est consultable avec la syntaxe @customer.tier:premium dans Datadog.

Les codes de statut renvoyés par l'API HTTP sont :

  • 202 : accepté : la requête a été acceptée pour traitement
  • 400 : requête incorrecte (probablement un problème de formatage de la charge utile)
  • 401 : non autorisé (probablement une clé API manquante)
  • 403 : problème d'autorisation (probablement une clé API invalide)
  • 408 : délai d'attente de la requête, la requête doit être retentée après un certain délai
  • 413 : charge utile trop volumineuse (le lot dépasse 5 Mo non compressé)
  • 429 : trop de requêtes, la requête doit être retentée après un certain délai
  • 500 : erreur interne du serveur, le serveur a rencontré une condition inattendue l'empêchant de traiter la requête, celle-ci doit être retentée après un certain délai
  • 503 : service indisponible, le serveur n'est pas en mesure de traiter la requête, probablement en raison d'une surcharge, la requête doit être retentée après un certain délai.

Requête

Body Data (required)

Événement côté serveur à envoyer (format JSON).

Champ
Type
Description
account
object

Un événement Product Analytics côté serveur.

application [required]
object

The application in which you want to send your events.

event [required]
object

Fields used for the event.

session
object

The session linked to your event.

type [required]
enum

The type of Product Analytics event. Must be server for server-side events.

Allowed enum values: server
usr
object

The user linked to your event.

Réponse

Request accepted for processing (always 202 empty JSON).

No response body

Exemple de code

Envoyer des événements côté serveur
## default

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with account ID
# Send a server-side event linked to an account.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "account": {
    "id": "account-456"
  },
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "checkout.completed"
  },
  "type": "server"
}
EOF

## Event with custom attributes
# Send a server-side event with additional custom attributes.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "customer": {
    "tier": "premium"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with session ID
# Send a server-side event linked to a session.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "form.submitted"
  },
  "session": {
    "id": "session-789"
  },
  "type": "server"
}
EOF

## Simple event with user ID
# Send a server-side event linked to a user.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF
## default

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-us3-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with account ID
# Send a server-side event linked to an account.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-us3-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "account": {
    "id": "account-456"
  },
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "checkout.completed"
  },
  "type": "server"
}
EOF

## Event with custom attributes
# Send a server-side event with additional custom attributes.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-us3-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "customer": {
    "tier": "premium"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with session ID
# Send a server-side event linked to a session.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-us3-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "form.submitted"
  },
  "session": {
    "id": "session-789"
  },
  "type": "server"
}
EOF

## Simple event with user ID
# Send a server-side event linked to a user.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-us3-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF
## default

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-us5-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with account ID
# Send a server-side event linked to an account.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-us5-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "account": {
    "id": "account-456"
  },
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "checkout.completed"
  },
  "type": "server"
}
EOF

## Event with custom attributes
# Send a server-side event with additional custom attributes.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-us5-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "customer": {
    "tier": "premium"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with session ID
# Send a server-side event linked to a session.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-us5-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "form.submitted"
  },
  "session": {
    "id": "session-789"
  },
  "type": "server"
}
EOF

## Simple event with user ID
# Send a server-side event linked to a user.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-us5-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF
## default

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-datadoghq.eu/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with account ID
# Send a server-side event linked to an account.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-datadoghq.eu/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "account": {
    "id": "account-456"
  },
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "checkout.completed"
  },
  "type": "server"
}
EOF

## Event with custom attributes
# Send a server-side event with additional custom attributes.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-datadoghq.eu/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "customer": {
    "tier": "premium"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with session ID
# Send a server-side event linked to a session.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-datadoghq.eu/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "form.submitted"
  },
  "session": {
    "id": "session-789"
  },
  "type": "server"
}
EOF

## Simple event with user ID
# Send a server-side event linked to a user.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-datadoghq.eu/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF
## default

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-ap1-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with account ID
# Send a server-side event linked to an account.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-ap1-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "account": {
    "id": "account-456"
  },
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "checkout.completed"
  },
  "type": "server"
}
EOF

## Event with custom attributes
# Send a server-side event with additional custom attributes.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-ap1-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "customer": {
    "tier": "premium"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with session ID
# Send a server-side event linked to a session.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-ap1-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "form.submitted"
  },
  "session": {
    "id": "session-789"
  },
  "type": "server"
}
EOF

## Simple event with user ID
# Send a server-side event linked to a user.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-ap1-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF
## default

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-ap2-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with account ID
# Send a server-side event linked to an account.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-ap2-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "account": {
    "id": "account-456"
  },
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "checkout.completed"
  },
  "type": "server"
}
EOF

## Event with custom attributes
# Send a server-side event with additional custom attributes.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-ap2-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "customer": {
    "tier": "premium"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with session ID
# Send a server-side event linked to a session.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-ap2-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "form.submitted"
  },
  "session": {
    "id": "session-789"
  },
  "type": "server"
}
EOF

## Simple event with user ID
# Send a server-side event linked to a user.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-ap2-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF
## default

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-uk1-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with account ID
# Send a server-side event linked to an account.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-uk1-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "account": {
    "id": "account-456"
  },
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "checkout.completed"
  },
  "type": "server"
}
EOF

## Event with custom attributes
# Send a server-side event with additional custom attributes.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-uk1-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "customer": {
    "tier": "premium"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF

## Event with session ID
# Send a server-side event linked to a session.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-uk1-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "form.submitted"
  },
  "session": {
    "id": "session-789"
  },
  "type": "server"
}
EOF

## Simple event with user ID
# Send a server-side event linked to a user.

# Set your Datadog credentials
export DD_API_KEY="<DD_API_KEY>"

curl -X POST "https://browser-intake-uk1-datadoghq.com/api/v2/prodlytics" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
  "application": {
    "id": "123abcde-123a-123b-1234-123456789abc"
  },
  "event": {
    "name": "payment.processed"
  },
  "type": "server",
  "usr": {
    "id": "123"
  }
}
EOF