Skip to main content
Version: 1.2.0

Choice Event

An example event that uses oneOf and anyOf.

DataLayer Examples

user_id options:

window.dataLayer.push({
"$schema": "https://tracking-docs-demo.buchert.digital/schemas/1.2.0/events/choice-event.json",
"event": "one_of_event",
"user_id": "user-123",
"payment_method": {
"payment_type": "credit_card",
"card_number": "1234-5678-9012-3456",
"expiry_date": "12/26"
}
});

payment_method options:

window.dataLayer.push({
"$schema": "https://tracking-docs-demo.buchert.digital/schemas/1.2.0/events/choice-event.json",
"event": "one_of_event",
"user_id": "user-123",
"payment_method": {
"payment_type": "credit_card",
"card_number": "1234-5678-9012-3456",
"expiry_date": "12/26"
}
});

Event Properties

PropertyTypeConstraintsExamplesDescription
$schemastringconst: "https://tracking-docs-demo.buchert.digital/schemas/1.2.0/events/choice-event.json"
"https://tracking-docs-demo.buchert.digital/schemas/1.2.0/events/choice-event.json"
Defines the structure of the event. This can be used to validate an event against the schema provided.
eventstringrequired
"one_of_event"
const: "one_of_event"

Select one of the following options:

The user's ID.

The user's ID as a string.

user_idstringrequired
"user-123"
The user's ID as a string.

The user's ID as an integer.

{}payment_methodobjectrequiredThe user's payment method.

Select any of the following options:

View Raw JSON Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://tracking-docs-demo.buchert.digital/schemas/1.2.0/events/choice-event.json",
"title": "Choice Event",
"description": "An example event that uses oneOf and anyOf.",
"type": "object",
"allOf": [
{
"$ref": "./events/components/dataLayer.json"
}
],
"required": [
"event",
"user_id",
"payment_method"
],
"properties": {
"$schema": {
"type": "string",
"description": "Defines the structure of the event. This can be used to validate an event against the schema provided.",
"const": "https://tracking-docs-demo.buchert.digital/schemas/1.2.0/events/choice-event.json"
},
"event": {
"type": "string",
"const": "one_of_event"
},
"user_id": {
"description": "The user's ID.",
"oneOf": [
{
"type": "string",
"title": "User ID as String",
"description": "The user's ID as a string.",
"examples": [
"user-123"
]
},
{
"type": "integer",
"title": "User ID as Integer",
"description": "The user's ID as an integer.",
"examples": [
123
]
}
]
},
"payment_method": {
"description": "The user's payment method.",
"type": "object",
"anyOf": [
{
"title": "Credit Card",
"type": "object",
"properties": {
"payment_type": {
"type": "string",
"enum": [
"credit_card",
"debit_card"
],
"examples": [
"credit_card"
]
},
"card_number": {
"type": "string",
"examples": [
"1234-5678-9012-3456"
]
},
"expiry_date": {
"type": "string",
"examples": [
"12/26"
]
}
},
"required": [
"card_number",
"expiry_date"
]
},
{
"title": "PayPal",
"type": "object",
"properties": {
"payment_type": {
"type": "string",
"const": "paypal"
},
"email": {
"type": "string",
"format": "email",
"examples": [
"test@example.com"
]
}
},
"required": [
"email"
]
}
]
}
}
}