Skip to content

Instantly share code, notes, and snippets.

View brunomertins's full-sized avatar

Bruno Mertins brunomertins

View GitHub Profile
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 17 columns, instead of 11. in line 3.
hostname,page,previous_page,pagepath_level_1,pagepath_level_2,pagepath_level_3,pagepath_level_4,page_title,landing_page,second_page,exit_page,entrances,pageviews,unique_pageviews,pages_per_session,exits,exit_rate
orangevalley.nl,https://orangevalley.nl/werken-bij/senior-content-consultant,,/werken-bij,/senior-content-consultant,,,Senior Content Consultant | Werken bij OrangeValley,https://orangevalley.nl/werken-bij/senior-content-consultant,,https://orangevalley.nl/werken-bij/senior-content-consultant,68,68,68,1.0,68,1.0
orangevalley.nl,https://orangevalley.nl/,,,,,,OrangeValley - Grensverleggend in Online Marketing,https://orangevalley.nl/,,https://orangevalley.nl/,387,387,386,1.0025906735751295,387,1.0
orangevalley.nl,https://orangevalley.nl/display-advertising/doubleclick/doubleclick-bid-manager/,,/display-advertising,/doubleclick,/doubleclick-bid-manager,,Google Marketing Platform: Display en Video 360 | OrangeValley,https://orangevalley.nl/display-advertising/doubleclick/doubleclick-bid-manager/,,https:/
WITH
-- Subquery to define static and/or dynamic start and end date for the whole query
period AS (
SELECT
'20200220' AS start_date,
FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)) AS end_date),
-- Subquery to prepare and calculate page view data
pages AS (
SELECT
user_pseudo_id,
WITH
-- Subquery to define static and/or dynamic start and end date for the whole query
period AS (
SELECT
'20200220' AS start_date,
FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)) AS end_date)
SELECT
-- Event count per user (metric | the number of times an individual event (change event_name 'page_view' to event that needs to be counted) was triggered divided by amount of users)
COUNT(DISTINCT
CASE
WITH
-- Subquery to set the start and end date once for the whole query
period AS (
SELECT
'20200220' AS start_date,
FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)) AS end_date),
-- Subquery to prepare and calculate traffic source data based on user and session id
traffic AS (
SELECT
user_pseudo_id,
SELECT
-- Date (dimension)
event_date AS date,
-- Year (dimension)
FORMAT_DATE('%Y', PARSE_DATE("%Y%m%d",
event_date)) AS year,
-- ISO Year (dimension)
FORMAT_DATE('%G', PARSE_DATE("%Y%m%d",
event_date)) AS iso_year,
-- Month of Year (dimension)
Field name Data type Description
App
app_info RECORD A record of information on the app.
app_info.id STRING The package name or bundle ID of the app.
app_info.firebase_app_id STRING The Firebase App ID associated with the app
app_info.install_source STRING The store that installed the app.
app_info.version STRING The app's versionName (Android) or short bundle version.
Device
device RECORD A record of device information.
device.category STRING The device category (mobile, tablet, desktop).
<table>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">Dept, Title</th>
<th scope="col">Phone</th>
</tr>
</thead>
<tbody>