Skip to content
Richard Cowin edited this page Nov 28, 2023 · 2 revisions

Macros are useful when common attributes need to be used, but cannot be easily shared via inheritance.

Macros allow a set of attributes that needs to be duplicated in different places in the configuration to be specified in a defmacros section. When this is done

  "defmacros": {
        "click-event": {
            "source": "dom",
            "on": "click",
            "action": "event"
        }
    },

And then used in a metric as:

  {
    "macro": "click-event",
    "source": "button.cta",
    "tag": "clicked.button-cta"
  }

This would result in the following evaluation for the metric:

{
    "source": "dom",
    "on": "click",
    "action": "event", 
    "source": "button.cta",
    "tag": "clicked.button-cta"
}