Custom Event
A custom Firebase event example for mobile apps.
DataLayer Example
- Android Firebase (Kotlin)
- Android Firebase (Java)
- iOS Firebase (Swift)
- iOS Firebase (Obj-C)
firebaseAnalytics.logEvent("my_custom_event") {
param("custom_prop", "gold_user")
param("custom_value", 42.5)
param("custom_flag", 1L)
param("country", "DE")
param("status_code", "500")
param("region_bucket", "public-west")
param("sku", "SKU-12345")
}
Bundle eventParams = new Bundle();
eventParams.putString("custom_prop", "gold_user");
eventParams.putDouble("custom_value", 42.5);
eventParams.putLong("custom_flag", 1L);
eventParams.putString("country", "DE");
eventParams.putString("status_code", "500");
eventParams.putString("region_bucket", "public-west");
eventParams.putString("sku", "SKU-12345");
mFirebaseAnalytics.logEvent("my_custom_event", eventParams);
var eventParams: [String: Any] = [
"custom_prop": "gold_user",
"custom_value": 42.5,
"custom_flag": 1,
"country": "DE",
"status_code": "500",
"region_bucket": "public-west",
"sku": "SKU-12345"
]
Analytics.logEvent("my_custom_event", parameters: eventParams)
NSMutableDictionary *eventParams = [@{
@"custom_prop": @"gold_user",
@"custom_value": @(42.5),
@"custom_flag": @(1),
@"country": @"DE",
@"status_code": @"500",
@"region_bucket": @"public-west",
@"sku": @"SKU-12345"
} mutableCopy];
[FIRAnalytics logEventWithName:@"my_custom_event" parameters:eventParams];
Event Properties
| Property | Type | Constraints | Examples | Description |
|---|---|---|---|---|
| $schema | string | required | | Defines the structure of the event. |
const: "https://tracking-docs-demo.buchert.digital/schemas/1.3.0/mobile/custom-event.json" | ||||
| event | string | required | | Custom event name. |
| custom_prop | string | | An example custom event parameter. | |
| custom_value | number | | An example numeric custom event parameter. | |
| custom_flag | boolean | | An example boolean custom event parameter. | |
| country | string | not: { const: "US" } | | Country code that must not be US (demo for not + const rendering). |
| status_code | string | not: { anyOf: [{ const: "200" }, { pattern: "^2[0-9]{2}$" }, { enum: ["ok", "success"] }] } | | Complex not example: disallow success-like codes via nested anyOf. |
| region_bucket | string | not: { anyOf: [{ pattern: "^internal-" }, { enum: ["private", "secret"] }, { allOf: [{ minLength: 2 }, { maxLength: 2 }, { pattern: "^[A-Z]{2}$" }] }] } | | Complex not example: disallow restricted prefixes and exact values. |
| sku | string | not: { anyOf: [{ pattern: "^[0-9]{1,4}$" }, { enum: ["unknown", "tbd", "na"] }, { allOf: [{ pattern: "^[A-Z0-9_-]+$" }, { maxLength: 3 }] }] } | | Complex not example: disallow short numeric-only IDs and known placeholders. |
additionalPropertiesSchema constraintControls properties not listed in properties and not matched by patternProperties. | string, number, integer, boolean, null |
View Raw JSON Schema
{
: "https://json-schema.org/draft/2020-12/schema",
: "https://tracking-docs-demo.buchert.digital/schemas/1.3.0/mobile/custom-event.json",
"title": "Custom Event",
"description": "A custom Firebase event example for mobile apps.",
"x-tracking-targets": [
"android-firebase-kotlin-sdk",
"android-firebase-java-sdk",
"ios-firebase-swift-sdk",
"ios-firebase-objc-sdk"
],
"type": "object",
"properties": {
"$schema": {
"type": "string",
"description": "Defines the structure of the event.",
"const": "https://tracking-docs-demo.buchert.digital/schemas/1.3.0/mobile/custom-event.json"
},
"event": {
"type": "string",
"description": "Custom event name.",
"examples": [
"my_custom_event"
]
},
"custom_prop": {
"type": "string",
"description": "An example custom event parameter.",
"examples": [
"gold_user"
]
},
"custom_value": {
"type": "number",
"description": "An example numeric custom event parameter.",
"examples": [
42.5
]
},
"custom_flag": {
"type": "boolean",
"description": "An example boolean custom event parameter.",
"examples": [
true
]
},
"country": {
"type": "string",
"description": "Country code that must not be US (demo for not + const rendering).",
"not": {
"const": "US"
},
"examples": [
"DE"
]
},
"status_code": {
"type": "string",
"description": "Complex not example: disallow success-like codes via nested anyOf.",
"not": {
"anyOf": [
{
"const": "200"
},
{
"pattern": "^2[0-9]{2}$"
},
{
"enum": [
"ok",
"success"
]
}
]
},
"examples": [
"500"
]
},
"region_bucket": {
"type": "string",
"description": "Complex not example: disallow restricted prefixes and exact values.",
"not": {
"anyOf": [
{
"pattern": "^internal-"
},
{
"enum": [
"private",
"secret"
]
},
{
"allOf": [
{
"minLength": 2
},
{
"maxLength": 2
},
{
"pattern": "^[A-Z]{2}$"
}
]
}
]
},
"examples": [
"public-west"
]
},
"sku": {
"type": "string",
"description": "Complex not example: disallow short numeric-only IDs and known placeholders.",
"not": {
"anyOf": [
{
"pattern": "^[0-9]{1,4}$"
},
{
"enum": [
"unknown",
"tbd",
"na"
]
},
{
"allOf": [
{
"pattern": "^[A-Z0-9_-]+$"
},
{
"maxLength": 3
}
]
}
]
},
"examples": [
"SKU-12345"
]
}
},
"required": [
"$schema",
"event"
],
"allOf": [
{
"$ref": "https://tracking-docs-demo.buchert.digital/constraints/schemas/firebase/v1/flat-event-params.json"
}
]
}