# Pattern-Based and Visual Analytics for Visitor Analysis on Websites
## 5 Traffic Segmentation and Characterization
### Filtering Visits View  
We incorporated a query console to allow users to select a group of nodes that meet a certain criteria (notice the console at the top in Figure 4). The query console is an interface to the open-source project called Cytoscape by [31], which is responsible for the actual query expression evaluation. The queries that can be performed using the tool, supporting the base logic operators: \(\wedge\), \(\vee\), \(\
eg\) (AND, OR, NOT), relational operators (\(=,>,<,\leq,\geq\)), string matching, and others. The patterns follow a very similar syntax than the Disjunctive Normal Form (DNF, [32]). All capabilities are provided by Cytoscape and the full specification can be found in the documentation [31].  
Figure 9: Click Path. Navigation graph of a visit. The number at the edge’s center indicates the view step, and the one with a clock icon shows how long the previous page was viewed.  
For the visual model, we import the log files to Matomo, so we are able to query visits and pages based on their database structure [33]. The format follows the next grammar:  
\[group[attr\;OP\;val],group\in\{\texttt{node},\texttt{edge},className\}\]  
where:  
* \(className\) represents a custom class assigned to a particular data. In our case we have three classes: visit, page, and objective. So instead of using node or edge, we use such classes which are less abstract. For example, \(.\texttt{page}[attr\;OP\;val]\) will target only web page attributes, similarly \(.\texttt{visit}[attr\;OP\;val]\) will query for the visit information.
* \(attr\) represents the attribute used for filtering. Such attributes correspond to the context represented by the group. For the visit group, the attributes are: duration, country, browser, events, among others. In the case of the page group the attributes are: url, visits, pageviews, bounceRate, exitRate, avgTimeSpent, among others.
* \(OP\) represents any binary operator. Depending on the data type, certain operators can be used over the others. The available operators are: =,!=,?,!,?=,!=,!=,!=,!=,!=,!=.
* \(val\) is the value used for matching \(attr\) by the selected operator (\(OP\)). Depending on the data type of \(attr\), \(val\) is a string, a number or a boolean.  
The logical operators \(\wedge\), and \(\vee\) use the following format:  
* (**AND**): \[group_{1}[attr_{1}\;OP_{1}\;val_{1}]group_{2}[attr_{2}\;OP_{2}\;val_{2}]\dots \;group_{n}[attr_{n}\;OP_{n}\;val_{n}]\] Notice the join of groups after the square brackets.
* (**OR**): \[group_{1}[attr_{1}\;OP_{1}\;val_{1}],group_{2}[attr_{2}\;OP_{2}\;val_{2}], \dots,group_{n}[attr_{n}\;OP_{n}\;val_{n}]\] Notice the use of the _comma_ (_) for concatenating conditions.  
The previous querying system enables us to enter patterns obtained with machine learning algorithms, such as the one presented in the next Section. In Table 4, we provide examples of how to use such query system to select a segment of traffic. In addition, in Figure 10 we can observe an example of the Visits view with a filter applied, highlighting the group of nodes that meet the specified criteria.  
\begin{table}
\begin{tabular}{l l l} \hline \hline
**Use Case** & **Segment Description** & **Query** \\ \hline Simple query with the.visit className & Visitors from the United States &.visit[countryCode = ‘us’] \\ Using the AND operator & Visitors using Google Chrome &.visit[browserCode = ‘CH’] \\ Using the OR operator & Visitors coming from Facebook &.visit[refernerName = ‘Facebook’],.visit[referrerName = ‘Inistagram’] \\ Using both AND and OR operators & Visitors from Mexico OR visitors from the United States that have 'us’],.visit[countryCode = ‘mx’] \\ \hline \hline \end{tabular}
\end{table}
Table 4: Query examples to filter visualization visit views.