Wiki: Search hits by page/Websites / Privacy Sensitive Analytics



The following Flux query can be used to retrieve results based on the page path (or a substring of it)

import "strings"

// Change this as needed
page="search-terms"


from(bucket: "telegraf/autogen")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r._measurement == "pf_analytics_test")
  |> filter(fn: (r) => r.type == "\"pageview\"")
  |> filter(fn: (r) => strings.containsStr(v: r.page, substr: page))
  |> pivot(rowKey:["_time", "sess_id", "page", "domain"], 
              columnKey: ["_field"], 
              valueColumn: "_value"
           )
  |> drop(columns: ["host", "_start", "_stop", "_measurement", "protocol"])
  |> group()