Skip to content

Attribute: key

Richard Cowin edited this page Nov 28, 2023 · 4 revisions

Key

The key attribute specifies where to get the value from the specific source as specified in the source attribute.

The source attribute is used with the key attribute to specify where the data for a metric will come from.

The following table explains the possible values for the source attribute.

Source Key (usage) Wiki Link
dom css selector Source: dom
expression js expression Source: expression
query name of query parameter Source: query
cookie cookie name Source: cookie
localStorage localStorage key Source: localStorage
sessionStorage sessionStorage key Source: sessionStorage
extension name of extension Source: extention
on-async expression to async function Source: on-async
promise coming soon...

Examples

DOM

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

Expression

{
  "source": "expression",
  "key": "window.data.productName",
  "action": "bind",
  "tag": "product.name"
}

Query

{
  "source": "query",
  "key": "utm_source",
  "action": "bind",
  "tag": "campaign.source"
}

localStorage

{
 "source": "localStorage",
 "key": "logged-in",
 "action": "bind",
 "type": "boolean",
 "tag": "user.logged-in"
}