package main
import (
"fmt"
"github.com/wacul/gasegment"
)
func main() {
// parse
segments, err := gasegment.Parse("users::condition::ga:pagePath==/abc")
if err != nil {
panic(err)
}
// modify
segments[0].Scope = gasegment.SessionScope
segments[0].Condition.AndExpression[0][0].Operator = gasegment.NotEqual
segments[0].Condition.AndExpression[0][0].Value = "cde"
// stringify
fmt.Println(segments.DefString())
}
$ go get -v github.com/wacul/gasegment/cmd/gasegment
$ echo "sessions::condition::ga:medium==referral" | gasegment
{
"name": "-",
"sessionSegment": {
"segmentFilters": [
{
"simpleSegment": {
"orFiltersForSegment": [
{
"segmentFilterClauses": [
{
"dimensionFilter": {
"dimensionName": "ga:medium",
"expressions": [
"referral"
],
"operator": "EXACT"
}
}
]
}
]
}
}
]
}
}