queries:tables:views

@views

Contains all page views made on the website. A page view represents a single HTTP Request made to a site which has DuckProve installed.

Structure

The following columns are available for the user agent.

Name Type Description
id Identifier Contains a unique identifier for this view.
parent_id Identifier Contains the id of the page view before this view.
session_id Identifier Contains an identifier which refers to the users session.
user_agent_id Identifier Contains an identifier which refers to the users browser information.
depth Number Contains the amount of views which have been made before this view.
url Literal Contains the url which was detected for this view.
captured Time Contains the time when this view was captured.
ended Time Contains the approximated time when the user finished looking at the page.

Example Query

The following query will output the average number of views made per session.

draw number using avg(maxdepth) as value from
(
    using max(depth) as maxdepth from @views
    group by session_id
) as depths

This example calculates the bounce rate using the views and the sessions table.

draw "line-chart"
using bounces.values / sessions.values * 100 as "y-value", bounces.captured as "x-value"
from 
(
    using count() as values, timefloor(c.captured) as captured
    from 
    (
        using sum(depth) as depthsum, timefloor(@views.captured) as captured 
        from @views
        group by sessionid, timefloor(@views.captured)
    ) as c
    where depthsum = 0
    group by timefloor(c.captured)
) as bounces
join
(
    using count() as values, timefloor(@sessions.captured) as captured
    from @sessions
    group by timefloor(@sessions.captured)
) as sessions on sessions.captured = bounces.captured

This query shows two different ways of measuring the time the user spends on a page.

draw "line-chart"
using round((ended - captured) / 5) * 5 as "x-value", count() as y-value, 'A' as line
from @views
group by "x-value"
having "x-value" < 300
union
using round((b.captured - a.captured) / 5) * 5 as "x-value", count() as "y-value", 'B' as line
from @views as a
join @views as b on a.id = b.parentid
group by "x-value"
having "x-value" < 300

IN THIS ARTICLE