-
Notifications
You must be signed in to change notification settings - Fork 0
Example: Segment
Richard Cowin edited this page Nov 28, 2023
·
3 revisions
For the Segment example, we use a macro to capture the details of setting up the monitoring of Segment's track
event.
The macro definition is as follows:
"defmacros": {
"segment": {
"comment": "Segment integration",
"poll": {
"duration": 1000
},
"source": "on-async",
"key": "window.analytics",
"on": "track",
"action": "event",
"extract": {
"expression": "params:at(0)"
}
}
},
The macro will extract the event name of Segment and allow it to be used in when
conditionals or to be used in a bind
statement.
After this macro has been setup, it can be used as follows:
"macro": "segment",
"apply": [
{
"when": "AddedToCart",
"extract": {
"expression": "params:at(1).itemName"
}
"apply": [
{"tag": "addedToCart.itemName", "action": "bind"},
{"when": "sofa", "tag": "addedToCart.sofa", "action": "event"}
]
}
]
}
In this example the first when will match on Segment event AddedToCart
and extract the propery named itemName
.
It will then produce the following two metrics:
- bind the value of
itemName
to audience attributeaddedToCart.itemName
- when the itemName matches on
sofa
it will create an evolv event calledaddedToCart.sofa