Skip to content

Instantly share code, notes, and snippets.

@maxim-uvarov
Created September 18, 2018 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxim-uvarov/b29440aa641253afbc4b7fccf4639e24 to your computer and use it in GitHub Desktop.
Save maxim-uvarov/b29440aa641253afbc4b7fccf4639e24 to your computer and use it in GitHub Desktop.
other
SELECT
REGEXP_EXTRACT(hits.page.pagePath, r'([^?&#]*)')AS landing_Page,
trafficSource.medium AS medium,
trafficSource.source AS source,
device.deviceCategory AS deviceCategory,
hits.contentGroup.contentGroup1 as contentGroup1,
date,
(SELECT x.value FROM UNNEST(hits.customDimensions) x WHERE x.index = 4) as type,
COUNT(totals.bounces) AS Bounces,
Count(totals.transactions) as transactions,
COUNT(totals.hits) AS Entrances
FROM
(Select * from `somehost.ga_sessions_201808*`
Union all
Select * from `somehost.ga_sessions_201809*`) AS GA,
UNNEST(GA.hits) AS hits
WHERE
hits.type="PAGE" AND hits.hitNumber=1 and trafficSource.medium = 'organic'
GROUP BY
landing_Page, medium, source, date, deviceCategory, contentGroup1, type
ORDER BY
Entrances desc limit 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment