@Leo1 , yes i got it.
I have on more question in the context of matomo, as i saw they have the custom dimensions inside action dimensions where we can define our custom event which we want to capture
For example if we declare the event of addToCart
then there is no option in matomo where we can define the fields which we want to capture in our addToCart event ? means where we can define our schema corresponding to our events and set the validations which fields are required or not
every field which we want to capture against addToCart are in free in nature. i.e means you can add whatever you want and send to the Matomo server
$("#btnAddToCartMatomo").click(function () {
console.log("Send add-to cart to matomo");
_paq.push([
"trackEvent",
"Category",
"AddtoWishlist",
JSON.stringify({
product_id: "P12345",
product_name: "Gaming Console PS5",
product_price: 50000.99,
product_qty: 1,
}),
]);
});
So in this, whatever extra field you can pass that will goes to the matomo server
But i dont want this, If this event fields are not satisfying to the schema then it would be maintain in somekind of error.log aur if satisy then only goes to the matomo server.
Do we need to rely on third-party libraries like Ajv or create your own validation functions to achieve this ?
or is there any somekind of plugin is available through which i can define the schema and validations according to my events
Below is the code of snowplow tracker where we are defining the schema
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Schema for an example event",
"self": {
"vendor": "com.snowplowanalytics",
"name": "example_event",
"format": "jsonschema",
"version": "1-0-0"
},
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 128
},
"job_role": {
"description": "",
"type": [
"string",
"null"
],
"maxLength": 128
},
"promo_code": {
"description": "",
"type": [
"string",
"null"
],
"minLength": 8,
"maxLength": 20
}
},
"additionalProperties": false,
"required": [
"name"
]
}
way to call this above snowplow schema , against our coming JSON payload
$("#btnSnowPlow").click(function () {
window.snowplow("trackSelfDescribingEvent", {
event: {
schema: "iglu:com.example/my-schema/jsonschema/1-0-0",
data: {
name: "John",
job_role: "CEO",
promo_code: "3306330877",
},
},
});
console.log("Snowplow success");
});
If it not satisy the schema, then it goes to bad state
Thanks Leo