{
  "$meta": {
    "package": "@walkeros/web-destination-matomo",
    "version": "4.2.1",
    "type": "destination",
    "platform": [
      "web"
    ],
    "docs": "https://www.walkeros.io/docs/destinations/web/matomo",
    "source": "https://github.com/elbwalker/walkerOS/tree/main/packages/web/destinations/matomo/src"
  },
  "schemas": {
    "mapping": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "goalId": {
          "description": "Goal ID to track a conversion alongside this event (like 1)",
          "type": "string"
        },
        "goalValue": {
          "description": "Property path for goal revenue value (like data.revenue)",
          "type": "string"
        },
        "siteSearch": {
          "description": "Track as internal site search using trackSiteSearch",
          "type": "boolean"
        },
        "contentImpression": {
          "description": "Track as content impression using trackContentImpression",
          "type": "boolean"
        },
        "contentInteraction": {
          "description": "Track as content interaction using trackContentInteraction",
          "type": "boolean"
        },
        "customDimensions": {
          "description": "Per-event custom dimension ID to property path mapping (like { \"3\": \"data.category\" })",
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "settings": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "siteId": {
          "type": "string",
          "minLength": 1,
          "description": "Matomo Site ID (like 1, 2, etc.)"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Base URL of your Matomo instance (like https://analytics.example.com/ or https://yourname.matomo.cloud/)"
        },
        "disableCookies": {
          "default": false,
          "description": "Disable all tracking cookies for cookie-free analytics",
          "type": "boolean"
        },
        "enableLinkTracking": {
          "default": true,
          "description": "Enable automatic outlink and download tracking",
          "type": "boolean"
        },
        "enableHeartBeatTimer": {
          "description": "Enable heart beat timer with interval in seconds for accurate time-on-page",
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "customDimensions": {
          "description": "Custom dimension ID to property path mapping applied to all events (like { \"1\": \"data.userType\" })",
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "required": [
        "siteId",
        "url"
      ],
      "additionalProperties": false
    }
  },
  "examples": {
    "env": {
      "init": {
        "window": {
          "location": {
            "href": "https://www.example.com/page"
          }
        },
        "document": {
          "createElement": {
            "$code": "()=>({type:\"\",src:\"\",async:!1,defer:!1})"
          },
          "head": {
            "appendChild": {
              "$code": "()=>{}"
            }
          }
        }
      },
      "push": {
        "window": {
          "_paq": [],
          "location": {
            "href": "https://www.example.com/page"
          }
        },
        "document": {
          "createElement": {
            "$code": "()=>({type:\"\",src:\"\",async:!1,defer:!1})"
          },
          "head": {
            "appendChild": {
              "$code": "()=>{}"
            }
          }
        }
      },
      "simulation": [
        "call:window._paq.push"
      ]
    },
    "step": {
      "customEvent": {
        "title": "Custom event with goal",
        "description": "A promotion visible event fires Matomo trackEvent and then trackGoal to record a goal conversion.",
        "in": {
          "name": "promotion visible",
          "data": {
            "name": "Setting up tracking easily",
            "position": "hero"
          },
          "context": {
            "ab_test": [
              "engagement",
              0
            ]
          },
          "globals": {
            "pagegroup": "homepage"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "a6e112d2b975cee4",
          "trigger": "visible",
          "entity": "promotion",
          "action": "visible",
          "timestamp": 1700000401,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "name": "trackEvent",
          "settings": {
            "goalId": "goal_1"
          },
          "data": {
            "set": [
              "data.name",
              "data.position"
            ]
          }
        },
        "out": [
          [
            "_paq.push",
            [
              "trackEvent",
              "Setting up tracking easily",
              "hero"
            ]
          ],
          [
            "_paq.push",
            [
              "trackGoal",
              "goal_1",
              null
            ]
          ]
        ]
      },
      "ecommerceCartUpdate": {
        "title": "Cart update",
        "description": "A cart view calls Matomo trackEcommerceCartUpdate with the nested product items and cart total.",
        "in": {
          "name": "cart view",
          "data": {
            "currency": "EUR",
            "value": 840
          },
          "context": {
            "shopping": [
              "cart",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "product",
              "data": {
                "id": "ers",
                "name": "Everyday Ruck Snack",
                "color": "black",
                "size": "l",
                "price": 420,
                "quantity": 2
              },
              "context": {
                "shopping": [
                  "cart",
                  0
                ]
              },
              "nested": []
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "76cb74c74eb2c692",
          "trigger": "load",
          "entity": "cart",
          "action": "view",
          "timestamp": 1700000403,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "name": "trackEcommerceCartUpdate",
          "data": {
            "set": [
              {
                "loop": [
                  "nested",
                  {
                    "condition": {
                      "$code": "e=>v(e)&&\"product\"===e.entity"
                    },
                    "map": {
                      "sku": "data.id",
                      "name": "data.name",
                      "category": {
                        "value": ""
                      },
                      "price": "data.price",
                      "quantity": {
                        "value": 1
                      }
                    }
                  }
                ]
              },
              "data.value"
            ]
          }
        },
        "out": [
          [
            "_paq.push",
            [
              "trackEcommerceCartUpdate",
              [
                {
                  "sku": "ers",
                  "name": "Everyday Ruck Snack",
                  "category": "",
                  "price": 420,
                  "quantity": 1
                }
              ],
              840
            ]
          ]
        ]
      },
      "ecommerceOrder": {
        "title": "Ecommerce order",
        "description": "A completed order calls Matomo trackEcommerceOrder with line items and order totals.",
        "in": {
          "name": "order complete",
          "data": {
            "id": "0rd3r1d",
            "currency": "EUR",
            "shipping": 5.22,
            "taxes": 73.76,
            "total": 555
          },
          "context": {
            "shopping": [
              "complete",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "product",
              "data": {
                "id": "ers",
                "name": "Everyday Ruck Snack",
                "color": "black",
                "size": "l",
                "price": 420
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "product",
              "data": {
                "id": "cc",
                "name": "Cool Cap",
                "size": "one size",
                "price": 42
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "gift",
              "data": {
                "name": "Surprise"
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "366edc1c00a0bd38",
          "trigger": "load",
          "entity": "order",
          "action": "complete",
          "timestamp": 1700000402,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "name": "trackEcommerceOrder",
          "data": {
            "set": [
              {
                "loop": [
                  "nested",
                  {
                    "condition": {
                      "$code": "e=>v(e)&&\"product\"===e.entity"
                    },
                    "map": {
                      "sku": "data.id",
                      "name": "data.name",
                      "category": {
                        "value": ""
                      },
                      "price": "data.price",
                      "quantity": {
                        "value": 1
                      }
                    }
                  }
                ]
              },
              {
                "map": {
                  "orderId": "data.id",
                  "grandTotal": "data.total",
                  "tax": "data.taxes",
                  "shipping": "data.shipping"
                }
              }
            ]
          }
        },
        "out": [
          [
            "_paq.push",
            [
              "trackEcommerceOrder",
              [
                {
                  "sku": "ers",
                  "name": "Everyday Ruck Snack",
                  "category": "",
                  "price": 420,
                  "quantity": 1
                },
                {
                  "sku": "cc",
                  "name": "Cool Cap",
                  "category": "",
                  "price": 42,
                  "quantity": 1
                }
              ],
              {
                "orderId": "0rd3r1d",
                "grandTotal": 555,
                "tax": 73.76,
                "shipping": 5.22
              }
            ]
          ]
        ]
      },
      "goalTracking": {
        "title": "Goal with value",
        "description": "A promotion event fires Matomo trackEvent and then trackGoal with a monetary goal value from event data.",
        "in": {
          "name": "promotion visible",
          "data": {
            "name": "Setting up tracking easily",
            "position": "hero",
            "value": 50
          },
          "context": {
            "ab_test": [
              "engagement",
              0
            ]
          },
          "globals": {
            "pagegroup": "homepage"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "a71cc94403b17e2d",
          "trigger": "visible",
          "entity": "promotion",
          "action": "visible",
          "timestamp": 1700000406,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "name": "trackEvent",
          "settings": {
            "goalId": "1",
            "goalValue": "data.value"
          },
          "data": {
            "set": [
              "data.name"
            ]
          }
        },
        "out": [
          [
            "_paq.push",
            [
              "trackEvent",
              "Setting up tracking easily"
            ]
          ],
          [
            "_paq.push",
            [
              "trackGoal",
              "1",
              50
            ]
          ]
        ]
      },
      "init": {
        "title": "Initialization",
        "description": "Destination bootstrap loads the Matomo tracker script and configures the tracker URL and site id.",
        "in": {
          "loadScript": true,
          "settings": {
            "siteId": "1",
            "url": "https://analytics.example.com/"
          }
        },
        "out": [
          [
            "_paq.push",
            [
              "setTrackerUrl",
              "https://analytics.example.com/matomo.php"
            ]
          ],
          [
            "_paq.push",
            [
              "setSiteId",
              "1"
            ]
          ],
          [
            "_paq.push",
            [
              "enableLinkTracking"
            ]
          ]
        ]
      },
      "pageView": {
        "title": "Page view",
        "description": "A page view is tracked in Matomo via trackPageView with the page title from event data.",
        "in": {
          "name": "page view",
          "data": {
            "domain": "www.example.com",
            "title": "walkerOS documentation",
            "referrer": "https://www.walkeros.io/",
            "search": "?foo=bar",
            "hash": "#hash",
            "id": "/docs/"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "pagegroup": "docs"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "bd9e14ed86bab505",
          "trigger": "load",
          "entity": "page",
          "action": "view",
          "timestamp": 1700000400,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "data": "data.title"
        },
        "out": [
          [
            "_paq.push",
            [
              "trackPageView",
              "walkerOS documentation"
            ]
          ]
        ]
      },
      "productDetailView": {
        "title": "Product detail view",
        "description": "A product view fires Matomo ecommerceProductDetailView with a single-product array.",
        "in": {
          "name": "product view",
          "data": {
            "id": "ers",
            "name": "Everyday Ruck Snack",
            "color": "black",
            "size": "l",
            "price": 420
          },
          "context": {
            "shopping": [
              "detail",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [],
          "consent": {
            "functional": true
          },
          "id": "8026617c83c8fbd8",
          "trigger": "load",
          "entity": "product",
          "action": "view",
          "timestamp": 1700000404,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "name": "ecommerceProductDetailView",
          "data": {
            "set": [
              {
                "set": [
                  {
                    "map": {
                      "sku": "data.id",
                      "name": "data.name",
                      "price": "data.price",
                      "quantity": {
                        "value": 1
                      }
                    }
                  }
                ]
              }
            ]
          }
        },
        "out": [
          [
            "_paq.push",
            [
              "ecommerceProductDetailView",
              [
                {
                  "sku": "ers",
                  "name": "Everyday Ruck Snack",
                  "price": 420,
                  "quantity": 1
                }
              ]
            ]
          ]
        ]
      },
      "siteSearch": {
        "title": "Site search",
        "description": "A search submit fires Matomo trackSiteSearch with the keyword, category, and number of results.",
        "in": {
          "name": "search submit",
          "data": {
            "query": "shoes",
            "category": "products",
            "resultsCount": 42
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "37474acc7d207a5f",
          "trigger": "test",
          "entity": "search",
          "action": "submit",
          "timestamp": 1700000405,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "name": "trackSiteSearch",
          "settings": {
            "siteSearch": true
          },
          "data": {
            "set": [
              "data.query",
              "data.category",
              "data.resultsCount"
            ]
          }
        },
        "out": [
          [
            "_paq.push",
            [
              "trackSiteSearch",
              "shoes",
              "products",
              42
            ]
          ]
        ]
      }
    }
  }
}