on
24 Nov 2022
11:05 PM
- edited on
13 Sep 2023
03:53 PM
by
HannahM
This page will serve as an overview of various USQL examples.
SELECT starttime, AVG(useraction.documentInteractiveTime) AS "DOM Interactive"
FROM usersession
WHERE country = "India"
GROUP BY starttimeSELECT starttime, AVG(useraction.networkTime) AS "Network time"
FROM usersession
WHERE country = "India"
GROUP BY starttimeSELECT country, AVG(useraction.serverTime) AS "Servertime"
FROM usersession
GROUP BY country limit 5SELECT country, AVG(useraction.visuallyCompleteTime) AS "Visually Complete"
FROM usersession
GROUP BY country limit 5SELECT country, COUNT(useraction.apdexCategory)
FROM usersession
WHERE useraction.apdexCategory = "FRUSTRATED"
GROUP BY country limit 5SELECT apdexCategory, COUNT(apdexCategory)
FROM useraction
WHERE apdexCategory != "UNKNOWN"
GROUP BY apdexCategorySELECT country, COUNT(useraction.name)
FROM usersession
WHERE useraction.name = "Loading of page /"
GROUP BY countrySELECT starttime, COUNT(useraction.name)
FROM usersession
WHERE useraction.name = "Loading of page /" AND country = "India"
GROUP BY starttimeSELECT DISTINCT DATETIME(starttime, 'MM-dd', '1d'), COUNT(*)
FROM usersession
WHERE useraction.internalApplicationId = "APPLICATIONID"SELECT apdexCategory, COUNT(apdexCategory)
FROM useraction
WHERE apdexCategory != "UNKNOWN" AND application="appnamehere"
GROUP BY apdexCategorySELECT DISTINCT useraction.name AS "User Action Name", useraction.application AS "Application", SUM(httpRequestsWithErrors) AS "HTTP Errors"
FROM useraction WHERE httpRequestsWithErrors IS NOT NULL
GROUP BY useraction.application, useraction.name, httpRequestsWithErrors
ORDER BY sum(httpRequestsWithErrors) DESC
LIMIT 20SELECT DISTINCT useraction.application AS "Application", SUM(httpRequestsWithErrors) AS "HTTP Errors"
FROM useraction
WHERE httpRequestsWithErrors IS NOT NULL
GROUP BY useraction.application, httpRequestsWithErrors
ORDER BY sum(httpRequestsWithErrors) DESC
LIMIT 20SELECT useraction.name as "Page Name", COUNT(*) as "Page Views", COUNT(DISTINCT usersession.internalUserId) AS "Unique Page Views", AVG(useraction.duration) As "Average Session", count(bounce) as "# Bounce sessions" FROM usersession WHERE bounce IS true GROUP BY useraction.nameSELECT COUNT(browserMajorVersion) as 'User Session Count', browserMajorVersion as 'Browser Version' FROM usersession GROUP BY browserMajorVersionSELECT FUNNEL(useraction.name='xxxxx' AS "Visits Store", useraction.name= 'xxxxxx' AS "Views Product", useraction.name = 'xxxxx' AS "Starts Checkout", useraction.name= 'xxxxx' AS "Offer Upsells", useraction.name = 'xxxxx' AS "Complete Purchase") FROM usersessionselect HOUR(usersession.startTime), usererror.name, count(usererror.name) from usererror where name="Script error." group by usererror.name,HOUR(usersession.startTime) order by usererror.name ASCThis is a great list of USQL for users starting out! thanks for sharing this @xu_guo
I agree this is a great post. Just the bounces part is misleading, since once the WHERE clause is bounce IS true, the number of "Page Views" will be the same as "Bounce sessions", since bounce sessions consist of exactly one page.
To get a better picture, a slight adjustment is needed:
SELECT useraction.name as "Page Name", COUNT(*) as "Page Views", COUNT(DISTINCT usersession.internalUserId) AS "Unique Page Views", AVG(useraction.duration) As "Average Session", CONDITION(COUNT(*) , WHERE bounce= true) as "# Bounce sessions" FROM usersession WHERE userType IS "REAL_USER" GROUP BY useraction.name