GMetri Webhooks
You can use Webhooks to get data from GMetri into your system/platform. Webhooks are supported for viewer's variable changes, session creations, and rule triggers.
GMetri Webhooks are pseudo real-time with a max delay of 60 seconds.
If there are a large number of responses, GMetri will batch responses in groups of 500, sent with a minimum gap of 200ms between consecutive queries.
GMetri doesn't have the ability to resend/retry webhooks incase of an error response.
post
https://example.com/user/endpoint
/gmetri-webhook
Webhook Response
Webhook Body
VariableWebhook
RuleWebhook
SessionWebook
type WebhookBody = {
type: "variables" | "session" | "rules",
data: { //WebhookData
orgSlug: string,
depSlug: string,
rows: (VariableWebhookData | SessionWebhookData | RuleWebhookData)[]
}
}
VariableWebhookData Type
type VariableWebhookData = {
identifier: string,
variables: Record<string, any>, //A map of variable name and value
};
Example Response with VariableWebhook:
Response Body
{
type: "variables",
data: {
orgSlug: "gmetri",
depSlug: "gmetridemo",
rows: [{
identifier: "[email protected]",
variables: {
score: 100,
quizCompleted: true,
}
}, {
identifier: "[email protected]",
variables: {
score: 75,
quizCompleted: false,
}
}]
}
}
RuleWebhookData Type
type RuleWebhookData = {
identifier: string,
rules: {
cid: number, //rule id
cname: string, //rule name
scene_name: string, //scene name where the rule was triggered
timestamp: number, // epoch ms
}[]
};
Example Webhook Response with RuleWebhook:
Response Body
{
type: "rules",
data: {
orgSlug: "gmetri",
depSlug: "gmetridemo",
rows: [{
identifier: "[email protected]",
rules: [{
cid: 1,
cname: "Rule A",
scene_name: "scene 1",
timestamp: 123456
}]
}, {
identifier: "[email protected]",
rules: [{
cid: 1,
cname: "Rule A",
scene_name: "scene 2",
timestamp: 123457
}, {
cid: 2,
cname: "Rule C",
scene_name: "scene 2",
timestamp: 123458
}]
}, {
identifier: "[email protected]",
rules: [{
cid: 10,
cname: "Rule G",
scene_name: "scene 4",
timestamp: 234561
}]
}]
}
}
SessionWebhookData Type
type SessionWebhookData = {
identifier: string,
session: Record<string, any>,
};
Example Response with VariableWebhook:
Response Body
{
type: "session",
data: {
orgSlug: "gmetri",
depSlug: "gmetridemo",
rows: [{
identifier: "[email protected]",
session: {
uuid: "12134-dffgs-2345-vfsd",
browser: "CHROME",
platform: "ANDROID,
device_id: "123",
created_at: 123455,
modified_at: 123455,
}
}, {
identifier: "[email protected]",
session: {
uuid: "12134-dffgs-2345-vfsd",
browser: "CHROME",
platform: "ANDROID,
device_id: "123",
created_at: xyz,
modified_at: xyz,
}
}, {
identifier: "[email protected]",
session: {
uuid: "12134-3214-2345-vfsd",
browser: "CHROME 1",
platform: "IOS",
device_id: "456",
created_at: 123456,
modified_at: 123456,
}
}]
}
Last modified 1yr ago