OWOX Data Marts — the new open-source analytics platform. Learn more at docs.owox.com

How to calculate visit start time?

NEW documentation: This article covers setup for OWOX BI. For the latest guides on setting up FREE connectors and Data Marts, visit the new OWOX Data Marts documentation.

This SQL query shows the start time of the session.

Parameters to set in the request

  • project-name — the name of the Google BigQuery project containing user session data uploaded via OWOX BI;
  • dataset-name — the name of the Google BigQuery dataset containing the session data;
  • _TABLE_SUFFIX — the date range you want to view data for.

SQL query

#standardSQL
SELECT
  sessionId,
  TIMESTAMP_MILLIS(timestamp) visitStartTime
FROM (
  SELECT
    sessionId,
    hits.timestamp,
    ROW_NUMBER() OVER(PARTITION BY sessionId ORDER BY hits.timestamp ASC) rowf
  FROM
    `project-name.dataset-name.owoxbi_sessions_*`,
    UNNEST (hits) hits
    WHERE _TABLE_SUFFIX BETWEEN '20191213' AND '20191214'
)
WHERE
  rowf = 1

 

Row sessionId visitStartTime
1 1111111111.111111113_1576240392308 2019-12-13 12:33:12.308 UTC
2 1111111111.22222223_1576248529623 2019-12-13 14:48:49.623 UTC
3 1111111111.33333333_1576330871973 2019-12-14 13:41:11.973 UTC
4 1111111111.44444447_1576312891097 2019-12-14 08:40:57.557 UTC
5 1111111111.555555555_1576298600061 2019-12-14 04:38:50.172 UTC
6 1111111111.666666666_1576299847255 2019-12-14 05:04:04.939 UTC
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.